Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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)



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using find range

Let me correct that
Rows("4").Columns("A" & rngcol).Interior.Color = RGB(221, 221, 221)

would be column A, rngcol - 1 rows below 4, which probably isn't what you
want. So,

I suspect you want to do the cell on row 4 at the rngcol location. That
would be

Cells(4,rngcol).Interior.Color = RGB(221, 221, 221)

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
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)





  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Using find range

Thanks for the help. What I am looking to color, is the entire row, columns A through whatever column rngcol is.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using find range

Range("A4").Resize(1, rngcol).Interior.Color = RGB(221, 221, 221)

--
Regards,
Tom Ogilvy

"Dan" wrote in message
...
Thanks for the help. What I am looking to color, is the entire row,

columns A through whatever column rngcol is.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Last cell in Range when range is date format default105 Excel Discussion (Misc queries) 5 July 7th 09 03:11 PM
Find the MAX number in range, then find... pgarcia Excel Discussion (Misc queries) 4 September 19th 08 06:58 PM
Find a range of values in a range of cells Jack Taylor Excel Worksheet Functions 20 November 25th 06 01:26 PM
Find dates in a range; then sum values in that range by a criteria Anders Excel Discussion (Misc queries) 4 October 21st 05 03:41 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM


All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"