0

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

  • 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
  • I got my all VBA Excel macros converted here. This is a very good service digitalthoughts.science/contact – Code Guy Apr 3 at 13:45
2

Short answer

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

Explanation

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.

References

| improve this answer | |

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