Selecting a Row based on cell value

  • Thread starter Thread starter Guest
  • Start date Start date
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,223,375
Messages
6,171,736
Members
452,419
Latest member
mapa

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