© Merry L. Morris
Introduction to writing simple macros
Writing OCLC Connexion Client Macros
OCLC Connexion Client Macro Mini-tutorial (Some of) My OCLC Connexion Client Mini-macros
Writing Microsoft Excel Macros
Excel macro mini-tutorial
Excel Macros Simplified
(Some of) My Excel Mini-macros

Yes, you can create variables ...
the simple way!


---------------Excel Macros Mini-tutorial (continued)---------------



You can add variables to your Excel macros to make them even more useful. Most tutorials show you how to create variables using syntax that can look unfamiliar and daunting if you are not an experienced macro programmer.

As you can probably guess, I use a simpler way that is far less intimidating to people who don't understand programming.

Look at the two versions of my InsertSheets macro below:

Sub InsertSheets()
        Sheets.Add.Name="NewSheetName"
End Sub

This version of the macro is my simplified version of the macro generated by Excel's macro editor while I inserted a new worksheet and named it NewSheetName

Now look at the second version of the macro. This version allows the user to name the worksheet by entering the name in a simple input box.

Sub InsertSheets2()
Dim VariableSheetName As String
VariableSheetName = Inputbox("Sheet Name","Enter sheet name","")
        Sheets.Add.Name = VariableSheetName

End Sub



This is the input box ...



created by the second version of my macro. Type a name for the new sheet and click OK!

Now, wasn't THAT simple, too?!

Your homework assignment is:

Record a new macro and use the method described in this mini-lesson to create your own simple variables!