Send data from excel to google sheet but the code doesn't work.

9kitti

New Member
Joined
Jul 4, 2021
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
Send data from excel to google sheet but the code doesn't work.
I want to send data from excel in the range A2:T2 and in field U2 show the sending status whether it was sent successfully or not. I put it in a google sheet but the code doesn't work. I want to send range data
I took the example from
But was not successful I would like to ask all teachers to help give me advice.

VBA Code:
Sub submitForm()

    'Set http = CreatObject("MSXML2.ServerXMLHTTP")
     Set http = CreateObject("MSXML2.ServerXMLHTTP")
    strURL = "https://docs.google.com/forms/d/e/1FAIpQLSfn9d38o8bd8f91G2cVm1rdfbIz0_e6vijJQZD-qB5e3Q1A7g/formResponse?ifq"
    
    intTotalRows = ThisWorkbook.Sheets("Data").Cell(Rows.Count, 1).End(xlUp).Row
    strUniqueID = ThisWorkbook.Sheets("Data").Range("A27").Text
    
    For rowNo = 2 To inTotalRows
        
        strHoscode = ThisWorkbook.Sheets("Data").Range("A" & rowNo).Text
        strHos = ThisWorkbook.Sheets("Data").Range("B" & rowNo).Text
        strTotal_case = ThisWorkbook.Sheets("Data").Range("C" & rowNo).Text
        strTotal_money = ThisWorkbook.Sheets("Data").Range("D" & rowNo).Text
        strMoneyRecives = ThisWorkbook.Sheets("Data").Range("E" & rowNo).Text
        strTotal_caseRecives = ThisWorkbook.Sheets("Data").Range("F" & rowNo).Text
        strTotal_case_notRecives = ThisWorkbook.Sheets("Data").Range("G" & rowNo).Text
        strappeal_money = ThisWorkbook.Sheets("Data").Range("H" & rowNo).Text
        strappeal_case_recives = ThisWorkbook.Sheets("Data").Range("I" & rowNo).Text
        strappeal_case_notrecives = ThisWorkbook.Sheets("Data").Range("J" & rowNo).Text
        strHC_money = ThisWorkbook.Sheets("Data").Range("K" & rowNo).Text
        strHC_case = ThisWorkbook.Sheets("Data").Range("L" & rowNo).Text
        strAE_Money = ThisWorkbook.Sheets("Data").Range("M" & rowNo).Text
        strAE_Case = ThisWorkbook.Sheets("Data").Range("N" & rowNo).Text
        strPP_Money = ThisWorkbook.Sheets("Data").Range("O" & rowNo).Text
        strPP_Case = ThisWorkbook.Sheets("Data").Range("P" & rowNo).Text
        strOPFS_Money = ThisWorkbook.Sheets("Data").Range("Q" & rowNo).Text
        strOPFS_Case = ThisWorkbook.Sheets("Data").Range("R" & rowNo).Text
        strTotalBath = ThisWorkbook.Sheets("Data").Range("S" & rowNo).Text
        strTotalCase = ThisWorkbook.Sheets("Data").Range("T" & rowNo).Text
        strStatus = ThisWorkbook.Sheets("Data").Range("U" & rowNo).Text
    
        strData = "&entry.1409202324=" & strHoscode
        strData = "&entry.869567421=" & strHos
        strData = "&entry.1817716227=" & strTotal_case
        strData = "&entry.1058867388=" & strTotal_money
        strData = "&entry.1200554119=" & strMoneyRecives
        strData = "&entry.618879238=" & strTotal_caseRecives
        strData = "&entry.1326498046=" & strTotal_case_notRecives
        strData = "&entry.1999532598=" & strappeal_money
        strData = "&entry.1684112441=" & strappeal_case_recives
        strData = "&entry.896384008=" & strappeal_case_notrecives
        strData = "&entry.864200327=" & strHC_money
        strData = "&entry.1783506789=" & strHC_case
        strData = "&entry.1844433011=" & strAE_Money
        strData = "&entry.1012783967=" & strAE_Case
        strData = "&entry.118809898=" & strPP_Money
        strData = "&entry.840118038=" & strPP_Case
        strData = "&entry.760455949=" & strOPFS_Money
        strData = "&entry.824958677=" & strOPFS_Case
        strData = "&entry.658889761=" & strTotalBath
        strData = "&entry.1806805796=" & strTotalCase

        strFinalUrl = strURL & strData
        http.Open "POST", strFinalUrl, False
        http.send

        If http.statusText = "OK" Then
            ThisWorkbook.Sheets("Data").Range("U" & rowNo) = "OK"
            strUniqueID = strUniqueID + 1
            ThisWorkbook.Sheets("Data").Range("A27") = strUniqueID
            ThisWorkbook.Sheets("Data").Range("A" & rowNo) = strUniqueID
        End If
        
    Next
    
    MsgBox "Done"

End Sub

google sheet
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,223,875
Messages
6,175,114
Members
452,613
Latest member
amorehouse

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top