I'm a vba rookie and have working vba code to check the value of each cell in range b2:b4 and use each of these values to format size of text in each cell in range d2:d4.
ex: if b2 = 1, d2 is formatted 12; if b2 = 5, d2 is formatted 16
My questions: how can I efficiently repeat this for adjacent columns?
(for example with a loop or other method)
Here's what i have so far:
ex: if b2 = 1, d2 is formatted 12; if b2 = 5, d2 is formatted 16
My questions: how can I efficiently repeat this for adjacent columns?
(for example with a loop or other method)
Here's what i have so far:
Sub Changefont()
For Each cell In Range("b2:b4")
If Range("b" & cell.Row).Value = 1 Then
cell.Offset(0, 2).Font.Size = 12
ElseIf Range("b" & cell.Row).Value = 5 Then
cell.Offset(0, 2).Font.Size = 18
ElseIf Range("b" & cell.Row).Value = 9 Then
cell.Offset(0, 2).Font.Size = 24
Else: cell.Offset(0, 2).Font.Size = 8
End If
Next cell
End Sub
For Each cell In Range("b2:b4")
If Range("b" & cell.Row).Value = 1 Then
cell.Offset(0, 2).Font.Size = 12
ElseIf Range("b" & cell.Row).Value = 5 Then
cell.Offset(0, 2).Font.Size = 18
ElseIf Range("b" & cell.Row).Value = 9 Then
cell.Offset(0, 2).Font.Size = 24
Else: cell.Offset(0, 2).Font.Size = 8
End If
Next cell
End Sub