Home > Software engineering >  Excel Macro to change font in cell
Excel Macro to change font in cell

Time:11-25

I need a macro that will in my spreadsheet search for:

  1. In Colum B: find a cell that contains "H1 or H2 or H3 or H4"
  2. then when found, change the font to bold and underline in the text in Column A

CodePudding user response:

You should first answer these types of questions by using record macro.

CodePudding user response:

Dim LastRow As Long
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row

For I = 0 to LastRow
If Cells(I, 2).Value = "H2" OR If Cells(I, 2).Value = "H3" Then 
Cells(I, 2).Font.Bold = True 'Probably doesnt work search the syntax 
End If
Next I



There are mistake i think but the structure is something like this

  • Related