VBA MOD01 With and ...And With for easier coding

 With and ...And With for easier coding 



Public Sub With_Change_Font()
  Dim myRange As Range

Set myRange = Range("A10", "A" & Cells(Rows.Count, 1).End(xlUp).Row)
'Debug.Print myRange.Address
With myRange.Font
.Name = "Arial"
.Bold = True
.Size = 14

End With

End Sub




Public Sub With_Reset_Font()
  Dim myRange As Range

Set myRange = Range("A10", "A" & Cells(Rows.Count, 1).End(xlUp).Row)
'Debug.Print myRange.Address
With myRange.Font
.Name = "Calibri"
.Bold = False
.Size = 11

End With

End Sub





Comments

Popular posts from this blog

VBA01 Copy Resize Variably Sized Ranges

VBA MOD01 Passing Arguments to sub procedures (ByRef , By Val)

PY MOD01 Lecture 01