Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using find range
Dim rng as Range
Dim rngCol as Long Set rng = Range("2:2").Find(what:="Number", LookIn:=xlValues, _ lookat:=xlWhole, searchorder:=xlByColumns, MatchCase:=True) If Not rng Is Nothing Then rngcol = rng.Column Rows("4").Columns("A" & rngcol).Interior.Color = RGB(221, 221, 221) End if I am not sure what you want to color. The above would color the cell in the 4th row of the found column. if you want to do the entire column Columns(rngCol).Interior.Color = RGB(221,221,221) -- Regards, Tom Ogilvy "Dan" wrote in message ... With this piece of code, I'm wondering how to reference the resulting column from the find information in the rows.columns bit below that, normally I would just do .Columns("A:AN") or something similar, but I'm not sure how to replace "AN" with a variable, rngcol. I'm also not sure what to dim rng and rngcol as. Thanks for any help. Set rng = Range("2:2").Find(what:="Number", LookIn:=xlValues, _ lookat:=xlWhole, searchorder:=xlByColumns, MatchCase:=True) If Not rng Is Nothing Then rngcol = rng.Column Rows("4").Columns("A:rngcol").Interior.Color = RGB(221, 221, 221) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find Last cell in Range when range is date format | Excel Discussion (Misc queries) | |||
Find the MAX number in range, then find... | Excel Discussion (Misc queries) | |||
Find a range of values in a range of cells | Excel Worksheet Functions | |||
Find dates in a range; then sum values in that range by a criteria | Excel Discussion (Misc queries) | |||
Range.Find returns cell outside of range when range set to single cell | Excel Programming |