Selecting a Row based on cell value

G

Guest

Guest
I need a macro that will select a row and highlight yellow if the value in coulmn C is a particular value. Any ideas?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You can use conditional formatting to do this rather than a macro.

The macro would be something along the lines of

Sub Macro1()
'
'
For a = 1 To 100
locatione = "c" & a
data = Range(locatione).Value
If data = "x" Then
locatione = a & ":" & a
Rows(locatione).Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If
Next
End Sub
This message was edited by bobeuk on 2002-03-05 10:02
 
Upvote 0
I need a macro, because it is a bit more complicated than what I made it sound like. The only thing I cannot figure out how to handle is selecting the row.
 
Upvote 0
Is this the type of thing your after.
This would go from cell C1 to whereever data finished in column C and colour every row that had a value of 5 in column C


--
myRow = 1
Lastrow = Range("C65000").End(xlUp).Row
For i = 1 To Lastrow
Range("C" & myRow).Select
If ActiveCell.Value = 5 Then
Rows(myRow & ":" & myRow).Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If
myRow = myRow + 1
Next i

--

Rgds
AJ
 
Upvote 0
you can also get the current row into a variable or whatever, at any given point with
ActiveCell.Row
 
Upvote 0

Forum statistics

Threads
1,213,530
Messages
6,114,162
Members
448,554
Latest member
Gleisner2

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