Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Find in a dynamic column...

I know this is a stupid question and I'm sorry in advance!!!

Set ytdRng = LevelRng.Range("a1:a1000").Find(What:=prevName, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)


LevelRng is a range that points to the first cell in the column I want
to search... How do I have it search the whole column? I currently
have it searching a fixed range ("a1:a1000") and that works, but I'd
like it to just search to the bottom of the used cells in that column.
FYI, there are blank cells in the column...

Thanks,

Bill

  #2   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Find in a dynamic column...

replace
range("a1:a1000")

with
range(levelrng.range("a1"),levelrng.range("a65536" ).end(xlup))
--
JNW


"billboe" wrote:

I know this is a stupid question and I'm sorry in advance!!!

Set ytdRng = LevelRng.Range("a1:a1000").Find(What:=prevName, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)


LevelRng is a range that points to the first cell in the column I want
to search... How do I have it search the whole column? I currently
have it searching a fixed range ("a1:a1000") and that works, but I'd
like it to just search to the bottom of the used cells in that column.
FYI, there are blank cells in the column...

Thanks,

Bill


  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Find in a dynamic column...

If levelrng is not in the first row you'll get an error using
levelrng.range("a65536"). I know the OP states he is using a fixed range of
A1:A1000, but his code indicates this range is relative to levelrng.

Just in case levelrng might not be in row 1:
Range(levelrng, Cells(Rows.Count, levelrng.Column).End(xlUp))


"JNW" wrote:

replace
range("a1:a1000")

with
range(levelrng.range("a1"),levelrng.range("a65536" ).end(xlup))
--
JNW


"billboe" wrote:

I know this is a stupid question and I'm sorry in advance!!!

Set ytdRng = LevelRng.Range("a1:a1000").Find(What:=prevName, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)


LevelRng is a range that points to the first cell in the column I want
to search... How do I have it search the whole column? I currently
have it searching a fixed range ("a1:a1000") and that works, but I'd
like it to just search to the bottom of the used cells in that column.
FYI, there are blank cells in the column...

Thanks,

Bill


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Find in a dynamic column...

JMB wrote:
If levelrng is not in the first row you'll get an error using
levelrng.range("a65536"). I know the OP states he is using a fixed range of
A1:A1000, but his code indicates this range is relative to levelrng.

Just in case levelrng might not be in row 1:
Range(levelrng, Cells(Rows.Count, levelrng.Column).End(xlUp))


Thanks to you both for your responses! JMB was correct, levelrng was
not in the 1st row... However, I had a heck of a time to get this
running... I finally figured out that the sheet needed be activated
for it to work. At least, that is what made it work for me... Does
that make sense!?!?


Thanks again!!!

Bill

  #5   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Find in a dynamic column...

Sorry about that. Without qualifying the worksheet, it will run on the
active sheet. I should have done that, but I assumed you were either working
w/the active sheet or you were familiar w/fully qualifying the range.


With Worksheets("Sheet1")
Set ytdRng = .Range(levelrng, .Cells(.Rows.Count, levelrng.Column).End(xlUp))
.Find(What:=prevName, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
End With

or use the Parent property of levelrng
With levelrng.Parent
Set ytdRng = .Range(levelrng, .Cells(.Rows.Count, levelrng.Column).End(xlUp))
.Find(What:=prevName, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
End With


"billboe" wrote:

JMB wrote:
If levelrng is not in the first row you'll get an error using
levelrng.range("a65536"). I know the OP states he is using a fixed range of
A1:A1000, but his code indicates this range is relative to levelrng.

Just in case levelrng might not be in row 1:
Range(levelrng, Cells(Rows.Count, levelrng.Column).End(xlUp))


Thanks to you both for your responses! JMB was correct, levelrng was
not in the 1st row... However, I had a heck of a time to get this
running... I finally figured out that the sheet needed be activated
for it to work. At least, that is what made it work for me... Does
that make sense!?!?


Thanks again!!!

Bill


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
Dynamic Find T De Villiers[_62_] Excel Programming 4 July 28th 06 07:08 PM
Help with copying dynamic column selected based on remote cell value and dynamic formula fill ers Charts and Charting in Excel 0 March 1st 06 01:05 AM
Help with copying dynamic column selected based on remote cell value and dynamic formula fill ers Excel Programming 0 March 1st 06 01:05 AM
trying to find the smallest with dynamic column changes Andy Excel Discussion (Misc queries) 1 February 24th 06 09:07 PM
Dynamic Find and Replace String Within Functions Based on Column Values [email protected] Excel Programming 0 October 13th 05 06:16 PM


All times are GMT +1. The time now is 07:45 PM.

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"