VBA cell selection and format

M

MTBer

I have a macro that produces a list of cell references in this format o
sheet1, in cell A1:A3 (note the range can grow or shrink)

Sheet2!C15
Sheet2!D53
Sheet2!G70


what would be the best way to now highlight the cell references an
format the background of these cells
 
D

Dave Peterson

One way:

Option Explicit
Sub testme01()

Dim myRng As Range
Dim myCell As Range
Dim testRng As Range

With Worksheets("sheet1")
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))

For Each myCell In myRng.Cells
Set testRng = Nothing
On Error Resume Next
Set testRng = Range(myCell.Value)
On Error GoTo 0
If testRng Is Nothing Then
MsgBox "not a range!"
Else
testRng.Interior.ColorIndex = 3
End If
Next myCell
End With

End Sub
 
Top