0

What i'm trying to accomplish is to go through a specific Table Column and for each visible row return the value of that cell. This cell contains a formula that creates a JSON from values in the table in other columns. Here's an example of the column i want to loop through:

Json Output

Inside this loop i'm going to use each cell value and POST the JSON, but it needs to loop through and post for each cell in that columnn. Here is the VBA code I'm using to POST a single cell without the loop:

Sub FulcrumUpload()

Dim xhr As Object, thisRequest As String, JSONvalue As String

Set xhr = CreateObject("Microsoft.XMLHTTP")
thisRequest = "https://api.fulcrumapp.com/api/v2/records.json"

xhr.Open "POST", thisRequest, False
xhr.setRequestHeader "Accept", "application/json"
xhr.setRequestHeader "Content-type", "application/json"
xhr.setRequestHeader "X-ApiToken", "11111111111111"

xhr.Send Sheets("Fulcrum Upload").Range("V3").value

End Sub

1 Answer 1

1

Assuming your filtered data is in column V, from V3 onwards, perhaps something like:

Public Sub FulcrumUpload()
    Dim xhr As Object, thisRequest As String, rng As Range

    Set xhr = CreateObject("Microsoft.XMLHTTP")
    thisRequest = "https://api.fulcrumapp.com/api/v2/records.json"

    With ThisWorkbook.Worksheets("Fulcrum Upload")
        For Each rng In .Range("V3:V" & .Cells(.Rows.Count, "V").End(xlUp).Row).SpecialCells(xlVisible)
            If Not IsEmpty(rng) Then
                With xhr
                    .Open "POST", thisRequest, False
                    .setRequestHeader "Accept", "application/json"
                    .setRequestHeader "Content-type", "application/json"
                    .setRequestHeader "X-ApiToken", "11111111111111"
                    .send rng.Value
                End With
            End If
        Next
    End With
End Sub
Sign up to request clarification or add additional context in comments.

10 Comments

That worked perfectly!! Exactly what I needed. Thank you so much for responding so quickly
New Question Related to this:
Sorry I added it to the original question
Do i need to start a new question?
Did you really want two loops or did you just want if col Y empty then take value from Z? And yes it should be a new question.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.