You are on page 1of 3

Module-Piece of code to run

Macros can be accessed by running the code, assigning to any shape or button or through short cuts

1) Running a macro using different option


2) Display message with multiple lines
3) Absolute referencing
4) Relative Referencing
5) Protecting a macro code
6) Running a macro in another open workbook
7) Commenting and uncommenting
8) Learning variables
9) Use of Input box
10) Working with ranges, cells,
11) Selecting entire worksheet with cells
12) Selecting active cells with color
13) Adding and deleting sheets

Vbcrlf – break lines in messages

1) Printing Messages

Sub HelloWorld()

MsgBox "Hello World"

MsgBox "Another World"

End Sub

2) Two lines in message box

Sub HelloWorld()

MsgBox "Hello" & vbCrLf & "World" & vbCrLf & "How are you?"

End Sub

3) Record and Stop Macro and Run Macros


4) Absolute Referencing
5) Relative referencing
6) How to protect macros
7) Clear Active Cells Macro
8) Adding Buttons
9) Add a shape and assign macro

'Sub NewMacro()
'

' NewMacro Macro

'

' Keyboard Shortcut: Ctrl Shift + B

'

' Selection.Copy

' Selection.End(xlToLeft).Select

' Selection.End(xlUp).Select

' ActiveSheet.Paste

'End Sub

Sub LearningVariables()

Dim a As Integer

Dim name As String

a = 25

a=a+5

name = "Harshit"

MsgBox a

MsgBox name

End Sub

Sub LearningVariables2()

Dim age As Integer

Dim fname As String

Dim lname As String

age = InputBox("Your Age?")

fname = InputBox("First name?")

lname = InputBox("Last Name?")

MsgBox "First Name: " & fname & vbCrLf & "Last Name: " & lname & vbCrLf & "Age: " & age
End Sub

You might also like