Professional Documents
Culture Documents
MsgBox "Rajagiri"
End Sub
Sub first_macro()
MsgBox 100
End Sub
Sub cell_refernce()
ActiveCell.Value = "Rajagiri"
ActiveCell.Value = 40
End Sub
Sub cellref()
[F20].Value = 70
End Sub
Sub cellref()
[C2:C10].Value = "Rajagiri"
End Sub
Sub cellref()
Range("d2:d20") = "India"
End Sub
Calculator
Sub OpenCalculator()
Application.ActivateMicrosoftApp Index:=0
End Sub
Sub highlightCommentCells()
Selection.SpecialCells(xlCellTypeComments).Select
Selection.Style= "Note"
End Sub
It will check all the selected cells and highlight the cell with the Minimum value.
Sub highlightMinValue()
Dim rng As Range
For Each rng In Selection
If rng = WorksheetFunction.Min(Selection) Then
rng.Style = "Good"
End If
Next rng
End Sub
You can use this code if you want to add multiple worksheets in your workbook in a single shot.
When you run this macro code you will get an input box to enter the total number of sheets you
want to enter.
Sub InsertMultipleSheets()
Dim i As Integer
i = InputBox("Enter number of sheets to insert.", "Enter
Multiple Sheets")
Sheets.Add After:=ActiveSheet, Count:=i
End Sub
Protect Worksheet
If you want to protect your worksheet you can use this macro code.
Sub ProtectWS()
ActiveSheet.Protect "mypassword", True, True
End Sub
Un-Protect Worksheet
If you want to unprotect your worksheet you can use this macro code.
All you have to do just mention your password which you have used while protecting your
worksheet.
Sub UnprotectWS()
ActiveSheet.Unprotect "mypassword"
End Sub