Excel Tutorials | Macros Code

Insert Multiple Worksheets

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 Excel

Read More »

Delete all Inactive Worksheet

Sub DeleteWorksheets() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets If ws.name <> ThisWorkbook.ActiveSheet.name Then Application.DisplayAlerts = False ws.Delete Application.DisplayAlerts = True End If

Read More »

Hide Inactive Worksheet

Sub HideWorksheet() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets If ws.Name <> ThisWorkbook.ActiveSheet.Name Then ws.Visible = xlSheetHidden End If Next ws End Sub

Read More »

Print Custom Pages

Sub printCustomSelection() Dim startpage As Integer Dim endpage As Integer startpage = _ InputBox(“Please Enter Start Page number.”, “Enter Value”) If Not WorksheetFunction.IsNumber(startpage) Then MsgBox

Read More »

Print Selection

Sub printSelection() Selection.PrintOut Copies:=1, Collate:=True End Sub Excel Macro code to Print Selection in Excel sheet. This code will help you print selected range. You

Read More »

Print Narrow Margin

Sub printNarrowMargin() With ActiveSheet.PageSetup .LeftMargin = Application .InchesToPoints (0.25) .RightMargin = Application.InchesToPoints(0.25) .TopMargin = Application.InchesToPoints(0.75) .BottomMargin = Application.InchesToPoints(0.75) .HeaderMargin = Application.InchesToPoints(0.3) .FooterMargin = Application.InchesToPoints(0.3) End

Read More »

Print Comments

Print Comments Sub printComments() With ActiveSheet.PageSetup .printComments = xlPrintSheetEnd End With End Sub VBA macro code for Print Comments.  Use this macro to activate settings

Read More »

Highlight Greater than Values

Sub HighlightGreaterThanValues() Dim i As Integer i = InputBox(“Enter Greater Than Value”, “Enter Value”) Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, _ Operator:=xlGreater, Formula1:=i Selection.FormatConditions(Selection.FormatConditions.Count).S tFirstPriority With Selection.FormatConditions(1) .Font.Color

Read More »

Highlight Lower Than Values

Sub HighlightLowerThanValues() Dim i As Integer i = InputBox(“Enter Lower Than Value”, “Enter Value”) Selection.FormatConditions.Delete Selection.FormatConditions.Add _ Type:=xlCellValue, _ Operator:=xlLower, _ Formula1:=i Selection.FormatConditions(Selection.FormatConditions.Count).S tFirstPriority With

Read More »

Highlight Negative Numbers

Sub highlightNegativeNumbers() Dim Rng As Range For Each Rng In Selection If WorksheetFunction.IsNumber(Rng) Then If Rng.Value < 0 Then Rng.Font.Color= -16776961 End If End If

Read More »