1Private Sub CommandButton1_Click()
2
3Dim W As Worksheet
4Set W = ActiveSheet
5
6'Read column names from row 1. Should match Airtable column names. No empty columns.
7Dim fields As String
8colCount = 1
9Do Until IsEmpty(W.Cells(1, colCount))
10fields = fields & "&fields[]=" & W.Cells(1, colCount).Value
11colCount = colCount + 1
12Loop
13
14'Get the data from airtable, using
15' AAAA is airtable id, e.g. applasl3409sdfsdl
16' TTTT is table name in readable format, e.g. Customers
17' VVVV is viewname in readable format, e.g. Prospects
18' KKKK is API-key
19Dim http As New WinHttpRequest
20Dim resp As String
21Dim url As String
22
23url = "https://api.airtable.com/v0/AAAA/TTTT?api_key=KKKK&view=VVVV" & fields
24http.Open "GET", url, False
25http.Send
26
27Dim json As Object
28Set json = JsonConverter.ParseJson(http.ResponseText)
29
30respRecord = 1
31On Error GoTo Exit_Loop
32
33Do Until json("records")(respRecord)("fields")(W.Cells(1, 1).Value) = ""
34
35For respCol = 1 To colCount - 1
36 cellValue = json("records")(respRecord)("fields")(W.Cells(1, respCol).Value)
37 W.Cells(respRecord + 1, respCol).Value = cellValue
38Next
39respRecord = respRecord + 1
40Loop
41
42Exit_Loop:
43
44End Sub