+ Reply to Thread
Results 1 to 12 of 12

Get from Table + Search in Google + Enter to a new column

Hybrid View

  1. #1
    Registered User
    Join Date
    05-12-2011
    Location
    Istanbul
    MS-Off Ver
    Excel 2003
    Posts
    3

    Arrow Get from Table + Search in Google + Enter to a new column

    Hello forum,

    I am a newbie here and I need your help.

    I am trying to reorganise our customer database and I need to do this:

    I have at least 10000 customers in a column, I need to enter their name into Google Search and take the first search result websıte to a new column called WebSite.

    How can I do that?

    Thank you...

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Get from Table + Search in Google + Enter to a new column

    Hi, Not a lot of information to go on, however you can try this.

    This script will take any name in col "I" Google it. and will return the link to the page in col "J"

    I have also attached a workbook for ease of use. If you are going to use in another workbook you will need to set some Ref in vba editior before it will work. such as:

    Microsoft Internet Controls

    A test workbook is below. It takes several seconds for the data to populate and I have only about 6 names entered. So I imagine that 10000 names will take a bit of time.

    I would suggest you copy your names to this test book and try to run the script.

    Let me know how it works out.

    Sub RNG5000()
    Dim cel As Object, cell As Object
    Dim r As Range, r2 As Range
    Dim lrow As Long, NewLrow As Long
    Dim MyStr As String, MyStr2 As String
    Dim count, i As Integer, x As String
    Dim ie As InternetExplorer
    Dim NewSht As Worksheet, OldSht As Worksheet
    Dim IEDoc As Object
    Application.ScreenUpdating = False
    Set ie = CreateObject("InternetExplorer.application")
    lrow = Range("I65536").End(xlUp).Row
    Set r = Range("I2:I" & lrow)
    For Each cell In r
    MyStr = cell.Value
    With ie
    .Visible = False
    .Navigate ("http://www.google.com/")
    While .Busy Or .ReadyState <> 4
    DoEvents
    Wend
        .Document.all.q.Value = MyStr
        .Document.all.btnG.Click
    End With
    Application.Wait (Now + TimeValue("0:00:02"))
    Set OldSht = ActiveSheet
    Set NewSht = Sheets.Add
    Set IEDoc = ie.Document
        For i = 0 To IEDoc.Links.Length - 1
            'write the linking url to a cell
           'cell.Offset(, 1).Value = IeDoc.Links(i).href
         NewSht.Cells(i + 1, 1).Value = IEDoc.Links(i).href
     
        Next i
     
        NewLrow = NewSht.Range("A65536").End(xlUp).Row
        Set r2 = NewSht.Range("A1:A" & NewLrow)
        For Each cel In r2
     
        MyStr = LCase(MyStr)
        MyStr = Replace(MyStr, " ", "")
        MyStr2 = "http://www." & MyStr & ".com/"
        NewSht.Cells.Find MyStr2
     
     
        If cel.Value Like MyStr2 Then
            cell.Offset(, 1).Value = cel.Value 'IeDoc.Links(i).href
            Exit For
        End If
     
        Next cel
     
        Application.DisplayAlerts = False
        NewSht.Delete
        Application.DisplayAlerts = True
        OldSht.Columns("I:J").AutoFit
     
    Next cell
    HyperLink
    ie.Quit
    Set ie = Nothing
    Application.ScreenUpdating = True
    End Sub
    Sub HyperLink()
    Dim r As Range
    Dim myvalue As String
    Dim lastrow As Long
    lastrow = Range("J65536").End(xlUp).Row
       For Each r In Range("J2:J" & lastrow)
     
          If InStr(r, "http://") > 0 Or InStr(r, "www.") > 0 Then
             myvalue = r.Value
                Range(r.Address).Select
                   ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
                                                      Address:=myvalue, _
                                                      TextToDisplay:=myvalue
          End If
       Next r
        Range("J1").Select
    End Sub
    ,
    ...,,
    Attached Files Attached Files
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  3. #3
    Registered User
    Join Date
    05-12-2011
    Location
    Istanbul
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Get from Table + Search in Google + Enter to a new column

    Hello,

    It works but can not find a website of the companies. I don't know why but I entered about 20 entries and it could only find 3 of them.

    Is it normal?

  4. #4
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Get from Table + Search in Google + Enter to a new column

    Quote Originally Posted by tahiryildiz View Post
    Hello,

    It works but can not find a website of the companies. I don't know why but I entered about 20 entries and it could only find 3 of them.

    Is it normal?
    You could try to run a couple of times. I did notice that when I put the script together that at times it did skip some names.

    Can you list a few of the names it left blank. I Like to run some tests on your data. This scrpt only looks for ".com" maybe I could work on it when I get some time.

    .

  5. #5
    Registered User
    Join Date
    05-12-2011
    Location
    Istanbul
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Get from Table + Search in Google + Enter to a new column

    These are some of my entries:

    ÇAĞDAŞ TIP GEREÇLERİ SAN VE TİC.LTD
    İNTERDEKOR İLYAS ADUT
    ÖNALANLAR YAPI MALZEMELERİ A.Ş.
    ÖZDEMİR MAKİNE DIŞ TİC.MURAT ÖZDEMİ
    ADORE OYUNCAK VE EĞT.ARÇ.SAN.TİC.A.



    It commands to search but nothing happens, no entries...

    Maybe my proxy doesn't let Excel to do this,but I don't guess so.

    There should be a problem about something...

    After Edit:

    MY second try was this:

    Fotokritik http://www.fotokritik.com/
    Sigorta
    Turkiye http://www.turkiye.com/
    England
    DAF http://www.daf.com/
    Last edited by tahiryildiz; 05-13-2011 at 10:31 AM.

  6. #6
    Registered User
    Join Date
    08-16-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Get from Table + Search in Google + Enter to a new column

    Hi
    Its Nice program......
    Last edited by markandan26; 08-18-2012 at 03:31 AM.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Get from Table + Search in Google + Enter to a new column

    Hi Markandan,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. IF you create your own thread any advice will be tailored to your situation so you should include a description of what you've done and are trying to do, if you feel that this thread is particularly relevant to what you are trying to do by all means include a link to it

  8. #8
    Registered User
    Join Date
    08-16-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Get from Table + Search in Google + Enter to a new column

    Ya Sure..But am new to this..
    Last edited by markandan26; 08-20-2012 at 09:37 PM.

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Get from Table + Search in Google + Enter to a new column

    Markandan26,

    You will get all the help you need. But for that, you need to create a new thread as per what Kyle explained.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  10. #10
    Registered User
    Join Date
    08-16-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Get from Table + Search in Google + Enter to a new column

    Hi,
    I don,t no How to create thread. please guide me
    Thank U.........

  11. #11
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Get from Table + Search in Google + Enter to a new column

    Go to the Excel Programming / VBA / Macros Forum and click on the Post New Thread button near the top of the page at the left side. Make sure to give a clear and concise title to your thread and explain in detail what you want. Post a link to this thread if you think it would help to explain your need.

  12. #12
    Registered User
    Join Date
    08-16-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Get from Table + Search in Google + Enter to a new column

    Thank U Dude..............

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1