Highlighting entire row of Cells having 2 ranges of criteria

boomzboombam

New Member
Joined
Oct 7, 2014
Messages
2
I've been taking a course on VBA and understand it when he explains it but I've been struggling on my own.

I just got a job that has me going through huge data sets and I want to be able to highlight data in 2 rows for the first and last name.

So far here's the data that I have that will run it, but it won't highlight it like i want.

If anyone has any recommendations I'd be very thankful!!!

Thanks guys!!!

:)

"

Option Explicit


Sub selectrow()


Dim row_nUMBEr As Double
Dim first_NAMe As Range
Dim LASt_naME As Range
Dim rowRange As Range
row_nUMBEr = 1




Do
DoEvents
row_nUMBEr = row_nUMBEr + 1
Set first_NAMe = Range("B" & row_nUMBEr)
Set LASt_naME = Range("C" & row_nUMBEr)


If first_NAMe = "ANTHONY" & LASt_naME = "Brooks" Then
Set rowRange = Application.Range(first_NAMe).EntireRow.Select
rowRange.Cells.Interior.Color = vbRed


End If




Loop Until first_NAMe = ""


MsgBox "Completed"


End Sub

"
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

boomzboombam

New Member
Joined
Oct 7, 2014
Messages
2
I've been taking a course on VBA and understand it when he explains it but I've been struggling on my own.

I just got a job that has me going through huge data sets and I want to be able to highlight data in 2 rows for the first and last name.

So far here's the data that I have that will run it, but it won't highlight it like i want.

If anyone has any recommendations I'd be very thankful!!!

Thanks guys!!!

:)

"

"

I FIGURED OUT THE ANSWER, VERY EXCITED ABOUT IT!!!!!

BASICALLY I WROTE & AND SHOULD HAVE WROTE and IN THE MIDDLE INSTEAD

sorry about the caps,

and adjusted the "first_name.entirerows.cells.interior.color = VBred" row

but ya i really love the website and hope to get more involved!!!

Option Explicit


Sub selectrow()


Dim row_nUMBEr As Double
Dim first_NAMe As Range
Dim LASt_naME As Range
Dim rowRange As Range

row_nUMBEr = 1




Do
DoEvents
row_nUMBEr = row_nUMBEr + 1
Set first_NAMe = Range("B" & row_nUMBEr)
Set LASt_naME = Range("C" & row_nUMBEr)


If first_NAMe = "ANTHONY" And LASt_naME = "BROOKS" Then

LASt_naME.Cells.Interior.Color = vbRed

LASt_naME.EntireRow.Cells.Interior.Color = vbRed


' Set rowRange = Application.Range(first_NAMe).EntireRow.Select
' ActiveCell.Cells.Interior.Color = vbRed


End If




Loop Until first_NAMe = ""












MsgBox "Completed"


End Sub
Option Explicit


Sub selectrow()


Dim row_nUMBEr As Double
Dim first_NAMe As Range
Dim LASt_naME As Range
Dim rowRange As Range
row_nUMBEr = 1




Do
DoEvents
row_nUMBEr = row_nUMBEr + 1
Set first_NAMe = Range("B" & row_nUMBEr)
Set LASt_naME = Range("C" & row_nUMBEr)


If first_NAMe = "ANTHONY" & LASt_naME = "Brooks" Then
Set rowRange = Application.Range(first_NAMe).EntireRow.Select
rowRange.Cells.Interior.Color = vbRed


End If




Loop Until first_NAMe = ""


MsgBox "Completed"


End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,993
Messages
5,526,118
Members
409,685
Latest member
Bellybb

This Week's Hot Topics

Top