I have VBA on my xlsb. How can I convert it to Google Apps script?

VBA on Excel sheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
       If Range((Split(ActiveCell(1).Address(1, 0), "$")(0)) & "9").Value < Date Then
        ActiveSheet.Unprotect Password:="XXX" 'password
        Selection.Locked = True
        Selection.FormulaHidden = False
        ActiveSheet.Protect Password:="XXX" 'password
        MsgBox "Entry is prohibited", vbInformation, "Attention!"
    ElseIf Range((Split(ActiveCell(1).Address(1, 0), "$")(0)) & "9").Value = Date Then
        ActiveSheet.Unprotect Password:="XXX" 'password
        ActiveSheet.EnableSelection = xlNoRestrictions
    End If
End Sub

enter image description here

closed as off-topic by ale, serenesat, jonsca Feb 7 '18 at 23:36

  • This question does not appear to be about web applications within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    I'm voting to close this question as off-topic because it is more appropriate for Stack Overflow. However, it would likely be quickly closed there since there is no effort toward translating the program. Attempting the translation and then posting there with any difficulties is the best approach. – jonsca Feb 7 '18 at 23:36

Short answer

The script should be wrote by and end-user/developer.


Google Sheets doesn't include a way to automatically convert VBA code to Google Apps Scripts.

By the other hand not all the VBA statements, classes, methods, etc. have an equivalent on Google Apps Script and not all the Excel features have an equivalent on Google Sheets, so the task it's not just to convert each line from one platform to the other.

I.E. In VBA, Worksheet.Protect Method allows to set a password but in Google Apps Script Class Protection doesn't.


Not the answer you're looking for? Browse other questions tagged or ask your own question.