Excel – VBA – How to use Non-Contiguous range of cells

Here is a way to update a range that is not contiguous using VBA (Visual Basic for Applications):

Sub NonContiguous_Range_Example()

Dim oRng As Range

Set oRng = Range("A1, B5, C9")

oRng.Value = "45"

oRng.Interior.ColorIndex = 34

End Sub

 

The output will be as shown below:

dnd_NonContiguous

SOURCE

LINK (Vbadud.blogspot.com)

LANGUAGE
ENGLISH