Convert VBA Macro to Google Apps Script

267 views
Skip to first unread message

Salman Munaf

unread,
Aug 13, 2020, 3:07:23 PM8/13/20
to Google Apps Script Community

I have an excel document that has the following VBA macro running on it. I want to convert it to Google sheets. Can any help me to convert it?

Sub searchdata()
Dim erow As Long
Dim ws As Worksheet
Dim lastrow As Long
Dim count As Integer

lastrow = Sheet1.Cells(Rows.count, 1).End(xlUp).Row
For x = 2 To lastrow
If Sheet1.Cells(x, 1) = Sheet2.Range("C4") Then
Sheet2.Range("C8") = Sheet1.Cells(x, 8)
Sheet2.Range("C9") = Sheet1.Cells(x, 9)
Sheet2.Range("C10") = Sheet1.Cells(x, 3)
Sheet2.Range("C11") = Sheet1.Cells(x, 4)
Sheet2.Range("C12") = Sheet1.Cells(x, 5)
Sheet2.Range("C16") = Sheet1.Cells(x, 11)
Sheet2.Range("C17") = Sheet1.Cells(x, 12)
Sheet2.Range("C18") = Sheet1.Cells(x, 13)
Sheet2.Range("C19") = Sheet1.Cells(x, 17)
End If

Next x
End Sub

Steve Webster

unread,
Aug 13, 2020, 3:32:20 PM8/13/20
to google-apps-sc...@googlegroups.com
I can help, but directly. Please send email to st...@swgapps.com.

Kind Regards,

Steve Webster
SW gApps LLC, President 
GDE (Google Developer Expert)
Google Product Expert in: Google Apps Script, Drive, and Docs 
Google Vendor (2012-2013) || Google Apps Developer Blog Guest Blogger 
Add-ons: Text gBlaster 


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/a4332462-aab8-46c3-b289-698e875b6a99o%40googlegroups.com.

Darren D'Mello

unread,
Aug 16, 2020, 3:12:11 AM8/16/20
to google-apps-sc...@googlegroups.com
I think you can mimic the same by recording the sheet macro with a little manipulation.



--
Best,
Darren
Reply all
Reply to author
Forward
0 new messages