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

"
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

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