PDA

View Full Version : Solved: Select Specific Cell Range



lukecj
02-25-2010, 09:58 AM
I am working with this code...

Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "CASH/CHECKING ACCOUNT" _
Or (cell.Value) = "CHECKING ACCOUNT" _
Or (cell.Value) = "CASH/CHECKING ACCOUNT" _
Or (cell.Value) = "CASH/CHECKING ACCOUNT" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
del.Offset(0, 6).FormulaR1C1 = "Leave 100k"
del.EntireRow.Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If
End If
Next cell
On Error Resume Next
Instead of selecting the entire row (del.EntireRow.Select), how would I simply select a range like A6:G6. Essentially, I just want to highlight the range instead of the entire row. Thanks for the help.

mbarron
02-25-2010, 10:30 AM
Try this version:
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)

For Each cell In rng
If (cell.Value) = "CASH/CHECKING ACCOUNT" _
Or (cell.Value) = "CHECKING ACCOUNT" _
Or (cell.Value) = "CASH/CHECKING ACCOUNT" _
Or (cell.Value) = "CASH/CHECKING ACCOUNT" Then

Set del = cell
del.Offset(0, 6).FormulaR1C1 = "Leave 100k"
With Range(del, del.Offset(0, 6)).Interior
.ColorIndex = 7
.Pattern = xlSolid
End With

End If

Next cell
On Error Resume Next

lukecj
02-25-2010, 11:16 AM
That works perfectly. Thank you so much for taking the time. I really appreciate it.