For example,
the user types date in textbox1 and search text in textbox 2 and the related data from google sheet gets copied to excel sheet.
textbox1: 8/21/2015
textbox2: SEVILLA
Code: Select all
Sub QueryGoogleSheets()
Dim qt As QueryTable, url As String, key As String, gid As String
If ActiveSheet.QueryTables.Count > 0 Then ActiveSheet.QueryTables(1).Delete
ActiveSheet.Cells.clear
key = "1WopmB1ExWSNul9sw9n7I9FEyquS4AyEugt_fKQrHJSI"
url = "https://spreadsheets.google.com/tq?tqx=out:html&key=" & key
'if needs to include gid
gid = "2009384141"
url = url & "&gid=" & gid
Set qt = ActiveSheet.QueryTables.Add(Connection:="URL;" & url, _
Destination:=Range("$A$1"))
With qt
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.Refresh
End With
End Sub