51-60EXCEL VBA - Step-By-Step Guide To Learning Excel Programming Language For Beginners (Excel VBA Programming, Excel VBA Macro, Excel Visual Basic)
51-60EXCEL VBA - Step-By-Step Guide To Learning Excel Programming Language For Beginners (Excel VBA Programming, Excel VBA Macro, Excel Visual Basic)
You also should change the written code on Sheet1. Just add that one we’ve
just added to each sub procedure in the modules:
PUBLIC means that that procedure can be called from anywhere. You’ll even
notice that all of them are even in the Macros list, but those saying PRIVATE
aren´t.
Try its meaning by changing just one or two Modules, change the word
Public to Private, and try run it.
As it was a Private one, it couldn’t find it. Let’s change the word Private back
to Public, you’ll see that it will work.
So, Private ones can’t be called, Public ones can be called, even from the
Macros list. In other words, Privates can’t be linked, but Publics can.
We’ve seen the most basic functions of VBA. You should have a great idea
about VBA now. However, let’s do something much more professional: A
real calculator.
Adding Letters?
FORMS
Visual Basic for Applications in Excel has a very attractive feature called
Forms in which we can create a visual application like that we saw in the
beginning of this book. That’s how we’ll create the calculator.
Follow these steps:
That’s an userform. It will be used to create a Calculator this time. First, you
see a Box called “Controls” with several options inside. We’ll use it almost
all time, so don’t close it. In case you do it, ou can open it again by clicking
on View TAB, then on Toolbox.
Don´t close the properties Userform either. This will be the main tools
we’ll use for this project, and In this case, we won’t even touch a Excel
Spreadsheet.
In the properties window change these values:
Name: CalculatorProject
Caption: Calculator
Height: 260
Width: 200
Once it is selected, click on the upper side of the form, hold and drag to make
a rectangle which will be our screen for the calculator.