Code To Highlight Row When Data Is In AA

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,783
Office Version
  1. 365
Platform
  1. Windows
Hi. I need a code please that will highlight a single row according to C when there is data in AA. As you can see below rows 2, 6, 7 ,8 and 11 are single rows (groups of more than one row can be ignored like 3-5 and 9-10)

Book1
CAA
1CatCode
2AUA314 1022Data
3AUA618 2012
4AUA618 2012
5AUA618 2012
6AUA618 3012
7AUA620 2008
8AUA620 2017Data
9AUA620 3008
10AUA620 3008
11AUA620 3014
Sheet1


Below you can see rows 2 and 8 have data in AA so need highlighting, rows 6, 7 and 11 have no data in AA so don't need highlighting. It will be used on various files up to 100,000 rows and there may be groups of rows matching in C up to about 20. I have hidden other columns for clarity.

Book1
CAA
2AUA314 1022Data
3AUA618 2012
4AUA618 2012
5AUA618 2012
6AUA618 3012
7AUA620 2008
8AUA620 2017Data
9AUA620 3008
10AUA620 3008
11AUA620 3014
Sheet1


Thanks.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hey Dazz,

Trying using this. it will automatically highlight the entire row in yellow, when data exists in Column C and Column AA

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

  Dim c As Range, sh1 As Worksheet
  Set sh1 = Sheets("Sheet1") 'replace sheet1 with your sheet name
  For Each c In sh1.Range("C2", sh1.Cells(Rows.Count, "C").End(xlUp)) 'this looks for a value in column C
    If c.Offset(0, 24) <> "" Then ' this looks for a value in coumn AA, which is 24 offset from C
      c.EntireRow.Interior.Color = vbYellow
    End If
  Next
End Sub
 
Upvote 0
Use conditional formatting to highlight the entire row starting @ row 2 with formula:
Excel Formula:
=IF(OR(NOT(ISBLANK($AA2)),"Data"=$AA2),TRUE,FALSE)
 
Upvote 0
Hey Dazz,

Trying using this. it will automatically highlight the entire row in yellow, when data exists in Column C and Column AA

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

  Dim c As Range, sh1 As Worksheet
  Set sh1 = Sheets("Sheet1") 'replace sheet1 with your sheet name
  For Each c In sh1.Range("C2", sh1.Cells(Rows.Count, "C").End(xlUp)) 'this looks for a value in column C
    If c.Offset(0, 24) <> "" Then ' this looks for a value in coumn AA, which is 24 offset from C
      c.EntireRow.Interior.Color = vbYellow
    End If
  Next
End Sub
Thanks but that's not what I am after. This highlights every row that has data in AA, I need it to highlight just single rows.
 
Upvote 0
Use conditional formatting to highlight the entire row starting @ row 2 with formula:
Excel Formula:
=IF(OR(NOT(ISBLANK($AA2)),"Data"=$AA2),TRUE,FALSE)
Thanks but I need a code not a formula, also the word data is as an example. AA could contain any words.
 
Upvote 0
Thanks but I need a code not a formula, also the word data is as an example. AA could contain any words.
Yes, is why I used the
Excel Formula:
OR(NOT(ISBLANK(Cell)))
 
Upvote 0
Thanks but that's not what I am after. This highlights every row that has data in AA, I need it to highlight just single rows.
I am not sure I understand what you are asking for. You want Any row, where data exists in both Columns C and AA? Your statement

"I need it to highlight just single rows."

is a tad confusing.
 
Upvote 0
I am not sure I understand what you are asking for. You want Any row, where data exists in both Columns C and AA? Your statement
I never said any row that has data in C. I said it needs to look at C to distinguish whether it is a single row or it may be a group of rows that are the same. Please look at my original post with example.
 
Upvote 0
I never said any row that has data in C. I said it needs to look at C to distinguish whether it is a single row or it may be a group of rows that are the same. Please look at my original post with exaSo i

I never said any row that has data in C. I said it needs to look at C to distinguish whether it is a single row or it may be a group of rows that are the same. Please look at my original post with example.
So you want a highlight every time the first 6 characters of the data in column C changes? Let me as this a different way, what makes the "groups of rows" the same?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top