![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
I need a macro that will select a row and highlight yellow if the value in coulmn C is a particular value. Any ideas?
|
|
|
|
#2 |
|
New Member
Join Date: Feb 2002
Posts: 10
|
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 ] |
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
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.
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
|
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 |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
|
you can also get the current row into a variable or whatever, at any given point with
ActiveCell.Row |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|