Macro to Italicize a specific row of every worksheet

These VBA macros apply the same formatting to one row on every sheet at once, such as making row 1 italic, or styling the header row of every sheet.

Works inExcel 2010 and later, Windows and Mac
UndoNot possible. Save a copy first
Save asMacro-Enabled Workbook (.xlsm)

New to macros? See how to use the macros on this site: copy the code, paste it into a module with Alt + F11, and run it with Alt + F8.

Italicize a row on every sheet

The macro asks for a row number and makes that row italic on all worksheets:

Sub ItalicRowAllSheets()
    Dim ws As Worksheet, r As Long
    r = Application.InputBox("Row number to italicize:", Type:=1)
    If r < 1 Then Exit Sub
    For Each ws In Worksheets
        ws.Rows(r).Font.Italic = True
    Next ws
End Sub

Style the header row of every sheet

Make row 1 bold with a light green fill on all sheets:

Sub FormatHeaderRowAllSheets()
    Dim ws As Worksheet
    For Each ws In Worksheets
        With ws.Rows(1)
            .Font.Bold = True
            .Interior.Color = RGB(226, 239, 218)
        End With
    Next ws
End Sub

Change the RGB numbers for a different colour, or add lines such as .Font.Size = 12.

Do it without a macro

  1. Right-click any sheet tab and choose Select All Sheets.
  2. Format the row once. The change applies to every selected sheet.
  3. Right-click a tab and choose Ungroup Sheets, so later edits don’t hit every sheet.

Things to know

  • The macro changes hidden sheets too.
  • To format only some sheets, select their tabs first and use For Each ws In ActiveWindow.SelectedSheets.
  • Formatting can’t be undone after a macro, so try it on a copy first.

Related macros