Creating and working with classes in VBA is very different from working with js classes. In fact, JavaScript is a classless language – there is no such thing as a class. This is not so scary as it sounds though, as there are various ways to make JavaScript behave as if there were. 

There are plenty of articles on VBA classes on this site, or if they are new to you, perhaps you should take a look at Getting Started with Classes
Much of  the code referred to here is the mcpher library. You can find out how to include it in your project here.

Allocating memory for an instance of the class



Not so different there, but notice that the class in js is actually a call to a function. The constructor for this class looks like this, and if necessary any housekeeping associated with creating a new instance could be done inside this function. Note that defining a function in this way is the only time you need to put a semi-colon after the curly brackets (some interpreters don’t care, but strictly speaking it should be there


In VBA there is a fair amount of fuss around declaring get/let/set properties, and the allocation private space for them inside the class instance, but there is a good reason for this – to be able to separate readonly from read/write properties. Here is a couple of properties of the cCell class

in js, you declare a property just by mentioning it, but in doing so, it becomes readable and writable. Here is the .create method of the ccell class

by assigning values to this.column, this.parent etc., we create the property and can access it later.

Readonly properties

If you want to duplicate the behavior of VBA, you need to simulate the js class in another way. Here’s an example protecting a private copy of a property and exposing its value through a related method. The only thing with this is that you would need to define all methods inside the constructor for this class (rather than extending the prototype),  so that they could have the same visibility to the private property, as they have in VBA


In VBA, public methods are procedures associated with that class and get associated simply by being in the same class module. 

As previously mentioned, js doesn’t really have classes but there are a few ways of simulating class-like behavior. I prefer to use a function to define a class constructor, and then add methods to that function’s constructor using its prototype. You can see that in the create method above. Here is the entire ccell class converted to google apps script. It ends up being more concise than the VBA version.

and for comparision, here is the VBA version

For more like this, see  From VBA to Google Apps Script .  Much of  the code referred to here is the mcpher library. You can find out how to include it in your project here.

Transitioning is covered more comprehensively in my my book, Going Gas – from VBA to Apps script