My company is switching from Microsoft Office to Google Docs, I have this (several) code I want to use in Google Spreadsheets but I have no idea on how to do that.
C
Use GSpread.NET. to work with Google Spreadsheets by using Microsoft Excel API. You needn't rewrite all code, just replace CreateObject(Excel.Application) to CreateObject(GSpreadCOM.Application).
examples
This is currently impossible in google app script as there is neither worksheet selection change event nor selection change event in spreadsheet services. List of Google Spreadsheet events are Here.
But we have time driven triggers in GAS, through this you will be able to run a function at some particular time. In your case lets say morning 12AM. You have to write a function which will run at 12AM to go through all the sheets and then format Cells(Target.Row, 1) and Cells(Target.Row, 2) on to the format which you like.
Definitely you have to restructure your current spreadsheet... Welcome to Google App Scripting.
The function is structured like this:
Private Sub Worksheet_Change(ByVal Target As Range)
Statements here
End Sub
That would probably convert to something like:
function Worksheet_Change(ByVal) {
Statements Here;
};
Instead of End Sub
the function in JavaScript ends with a curly brace }
.
Instead of End If
, the If, then statement also ends with a curly brace }
.
if (condition) {code here;}
That's the syntax for a JavaScript If statement. There is no Then
key word in JavaScript.
If you want to convert from VBA tot GAS there is one site you really must look http://ramblings.mcpher.com/
If that site doesn't help, I guess you're in big trouble!
In 2020, Google released Macro Converter add-on, which automatically converts VBA to Apps Script.
Note: