We currently use Excel but want to move over to Google Sheets. I have copied the scripts that we use for Excel. How would I modify/add these to Google Sheets? It can be onClose
, but then I'd need it to clear any data we changed from the file.
Sub myCloseCode()'Standard module code, like: Module1.Dim strDate$, strCustomer$, strFileNm$, strMsg$, myUpDate$Application.EnableEvents = FalseOn Error GoTo myErr'Test for Save option or Exit without saving?strMsg = "Save this file before closing?"myUpDate = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Now?")'Chose "Yes" button!If myUpDate = 6 Then GoTo mySave'Chose "No" button!If myUpDate = 7 ThenApplication.EnableEvents = TrueExit SubEnd IfmySave:'Build file name!strDate = DatePart("m", Date) & "-" & _DatePart("d", Date) & "-" & _Right(DatePart("yyyy", Date, vbUseSystemDayOfWeek, vbUseSystem), 4)strCustomer = Sheets("Carolina Fireworks Order Form").Range("C8").ValuestrFileNm = "\\READYSHARE\USB_Storage\Carolina Fireworks Info\Customers\" & strCustomer & "-" & strDate & ".xlsm"'Save current file!ActiveWorkbook.SaveAs Filename:=strFileNmApplication.EnableEvents = TrueActiveWorkbook.CloseExit SubmyErr:'GoTo Error routine!Call myErrHandler(Err)Application.EnableEvents = TrueEnd SubPrivate Sub myErrHandler(myErr As ErrObject)'Standard module code, like: Module1.'Error Trap Routine!Dim myMsg$'Build Error Message!myMsg = "Error Number : " & Str(myErr.Number) & vbLf & _"Error Location: " & myErr.Source & vbLf & _"Error Description: " & myErr.Description & vbLf & vbLf & _"Context: " & myErr.HelpContext & vbLf & _"Help File: " & myErr.HelpFile'Show Error Message!MsgBox myMsg & vbLf & vbLf & _"Use the ""Help"" button for more information, on this ERROR!", _vbCritical + vbMsgBoxHelpButton, _Space(3) & "Error!", _myErr.HelpFile, _myErr.HelpContextEnd Sub