Sub Find_URLs_in_Google()
'https://www.mrexcel.com/board/threads/new-macros-needed.1150242
Dim co_name As String
sht_asheet_index = ActiveSheet.Index
lra = Sheets(sht_asheet_index).Range("a" & Rows.Count).End(3).Row
For company_count = 2 To lra
co_name = Sheets(sht_asheet_index).Range("A" & company_count).Value
Sheets.Add after:=Sheets(Sheets.Count)
On Error Resume Next
querry_add co_name
On Error GoTo -1
find_www_in_a company_count, sht_asheet_index
Sheets(Sheets.Count).Delete
Application.Wait (Now + #12:00:01 AM#)
Next company_count
End Sub
Private Sub querry_add(co_name As String)
search_link = "URL;https://www.google.com/search?q=""" & co_name & """"
'bounch of the below with part is not necessary, but i let it there
With ActiveSheet.QueryTables.Add(Connection:=search_link, Destination:=Range("$A$1"))
.Name = "search?q=""magnotta winery""#spf=1604993071782"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
Private Sub find_www_in_a(company_count, sht_asheet_index)
For Each cell In Range("A20:A70")
If Left(Trim(cell.Value), 3) = "www" Then www_row = cell.Row: GoTo exit_cell_loop
Next cell
Exit Sub
exit_cell_loop:
Sheets(sht_asheet_index).Range("b" & company_count).Value = Sheets(Sheets.Count).Range("A" & www_row).Value
Sheets(sht_asheet_index).Range("C" & company_count).Value = Sheets(Sheets.Count).Range("A" & www_row + 1).Value
End Sub