• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Automated Search Results Returning Nothing|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Automated Search Results Returning Nothing|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosAutomated Search Results Returning …
sp_PrintTopic sp_TopicIcon
Automated Search Results Returning Nothing
Avatar
Bill Jone
Member
Members
Level 0
Forum Posts: 32
Member Since:
July 17, 2019
sp_UserOfflineSmall Offline
1
October 3, 2020 - 2:58 am
sp_Permalink sp_Print

Hi,

 

Please can check why I get zero result when I run this macro.

 

Thanks;

Bill

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
October 4, 2020 - 11:23 am
sp_Permalink sp_Print

Hi Bill,

Please start your own topic if you have a question, don't tag on to someone else's topic.

Your code doesn't work because you're looking for an element in the HTML that doesn't exist

Set var1 = html.getelementbyid("resultStats")

If you load the search URL into your browser and then examine the source code of the results page, you'll see there isn't an element with the ID resultStats.  Modify the code to find the correct ID.

Regards

Phil

Avatar
Bill Jone
Member
Members
Level 0
Forum Posts: 32
Member Since:
July 17, 2019
sp_UserOfflineSmall Offline
3
October 6, 2020 - 7:13 am
sp_Permalink sp_Print

Hi Phil

It is working now. How kind you are to help me. Thank you very much.

I still need your help, I need to add new column to get the URL as I have some companies and I want to get their websites in separated column. please check attached file.

Thank you very much; your support is greatly appreciated.

Thanks;

Bill

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
October 6, 2020 - 9:06 am
sp_Permalink sp_Print

No problem Bill.

Where do you want to get the company website address from? 

Looking at the results I get when searching, for 3M the 1st search result has a website address, but there's also an address on the right hand side of the screen where there is specific company information.

My results for Toshiba don't show a web address on the right hand side.

So will you settle for the first result in search, which isn't necessarily going to be the company's website.

Regards

Phil

toshiba-search-result-1.pngImage Enlarger

3m-search-result-1.pngImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage toshiba-search-result-1.png (203 KB)
  • sp_PlupImage 3m-search-result-1.png (167 KB)
Avatar
Bill Jone
Member
Members
Level 0
Forum Posts: 32
Member Since:
July 17, 2019
sp_UserOfflineSmall Offline
5
October 6, 2020 - 10:59 pm
sp_Permalink sp_Print

Hi Phil,

Thank you very much; your support is greatly appreciated.

Please if you can update the macro by two results, each result will be in separated column.

Also I am surprised as I see google result have website for Toshiba, please check attached image.

Thanks again for all your assistance.

Thanks;

Bill

Toshiba-1.pngImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage Toshiba-1.png (135 KB)
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
October 7, 2020 - 8:48 am
sp_Permalink sp_Print

Hi Bill,

Google search results are location specific.  The results it gives me when I search here in Australia will most likely be different to what you see when you search - and your image verifies this.

I'm not sure what you mean by 'update the macro by two results, each result will be in separated column'?

Do you mean get 2 website addresses from the search results, 1 from the main results and the other from the company specific panel on the right hand side of the page?

Regards

Phil

Avatar
Bill Jone
Member
Members
Level 0
Forum Posts: 32
Member Since:
July 17, 2019
sp_UserOfflineSmall Offline
7
October 7, 2020 - 7:44 pm
sp_Permalink sp_Print

Hi Phil,

Yes please I want to 2 website addresses from the search results, 1 from the main results and the other from the company specific panel on the right hand side of the page.

I'm sure you are very busy, so when you have a chance please reply me.

That's a huge help - thanks!

Thanks;

Bill

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
8
October 9, 2020 - 12:09 pm
sp_Permalink sp_Print

Hi Bill,

This is proving to be very difficult to implement.  Google results are not in a fixed format.  Not only do the results vary by where you are when you do your search, they can vary by the network you are on, the browser you are using etc.

I've written code to pick out the info you need but it doesn't always work because the section of the results page that shows the company info and web address for 3M (for example) contains different info if I search for something else.  If I search for abbott italy I get a map at the top of the search results with various links and other info.

Getting inconsistent page layout of the results makes it very difficult to write any generic code to get the info you are after.

As we've already discussed, the results you see are different to what I see.  I'm getting results specifically tailored to being in Australia.  The info and website addresses for 3M are different to what you are seeing

Added to this a lot of the content of the page is not using easily identifiable elements.  Some parts of the HTML do not have an ID.  Most have CSS class names that look randomly generated.  Whilst they'd need to be consistent with the CSS rules in order for page styling to work, I have no idea if they will suddenly change a class name to something else.  If that happened, any code to identify an element on the page would stop working.

Sorry, I just can't get my code to consistently retrieve the data because the layout and content of the search result pages keeps changing.

Phil

Avatar
Bill Jone
Member
Members
Level 0
Forum Posts: 32
Member Since:
July 17, 2019
sp_UserOfflineSmall Offline
9
October 10, 2020 - 1:51 am
sp_Permalink sp_Print

Hi Phil,

Words cannot express how grateful I am for your help.

I got what you mean, currently the attached macro give the first result from google but the result contain that the website + Title in the same cell.

so Is there ability to get the hyperlinks only as below.

Searched word is 3M

Current result:  

Web results

3M Science. Applied to Life. 3M United Stateswww.3m.comwww.3m.com
Cached
3M applies science and innovation to make a real impact by igniting progress and inspiring innovation in lives and communities across the globe.
‎About 3M · ‎Products · ‎Covid-19 · ‎Personal Protective Equipment

Expected result from macro after the update:

https://www.3m.com/

I will always remember your kindness and support. Thank you very much!

Thanks;

Bill

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Andy Kirby, Shanna Getschel, Ryan Marceau, Darrell Hodge, Mike Green, Tiffany Kang
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 204
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Maria Conatser
Jefferson Granemann
Glen Coulthard
Nikki Fox
Rachele Dickie
Raj Mattoo
Mark Luke
terimeri dooriyan
Jack Aston
AndyC
Forum Stats:
Groups: 3
Forums: 24
Topics: 6221
Posts: 27285

 

Member Stats:
Guest Posters: 49
Members: 31908
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.