Seamus2626
asked on
Change Column Ref
Hi,
I have a sub below.
Instead of highlighting as far as Col G, i would like it to find the Column which has ("Grand Total in Row 4 and only highlight as far as that
Thanks
Seamus
Sub ASPASOPHISHKMATCH()
Dim wkb As Workbook
Dim wksA As Worksheet
Dim wksB As Worksheet
Dim rng As Range
Dim r As Range
Dim rFind As Range
Dim rColor As Range
Set wkb = ThisWorkbook
Set wksA = wkb.Sheets("ASPA HK")
Set wksB = wkb.Sheets("Sophis HK Pivot")
Set rng = wksA.Range("A5", wksA.Range("A" & Rows.Count).End(xlUp).Offs et(-1, 0))
For Each r In rng
Set rColor = wksA.Range(r, wksA.Cells(r.Row, "G"))
Set rFind = wksB.Range("A:A").Find(wha t:=r.value , LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlNext)
If Not rFind Is Nothing Then
rColor.Interior.Color = vbGreen
Else
rColor.Interior.Color = vbRed
End If
Next r
End Sub
I have a sub below.
Instead of highlighting as far as Col G, i would like it to find the Column which has ("Grand Total in Row 4 and only highlight as far as that
Thanks
Seamus
Sub ASPASOPHISHKMATCH()
Dim wkb As Workbook
Dim wksA As Worksheet
Dim wksB As Worksheet
Dim rng As Range
Dim r As Range
Dim rFind As Range
Dim rColor As Range
Set wkb = ThisWorkbook
Set wksA = wkb.Sheets("ASPA HK")
Set wksB = wkb.Sheets("Sophis HK Pivot")
Set rng = wksA.Range("A5", wksA.Range("A" & Rows.Count).End(xlUp).Offs
For Each r In rng
Set rColor = wksA.Range(r, wksA.Cells(r.Row, "G"))
Set rFind = wksB.Range("A:A").Find(wha
If Not rFind Is Nothing Then
rColor.Interior.Color = vbGreen
Else
rColor.Interior.Color = vbRed
End If
Next r
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Teylyn,
Thank you too Rory
Seamus
Thank you too Rory
Seamus
I would do this bit:
Open in new window
outside the loop as it doesn't change.