asked on # is there a better way of saying

SearchRange = Range("A1", Range("A65536").End(xlUp))

For i = Range("E65536").End(xlUp).Row To 1 Step -1

so that I am not quoting numbers [65536 etc]

Thanks

For i = Range("E65536").End(xlUp).

so that I am not quoting numbers [65536 etc]

Thanks

Microsoft Excel

The problem with activesheet.rows.count is that for example in Excel 2010 it will give you a value of 1048576, so better would be Activesheet.usedrange.rows.count.

so how do I put this

SearchRange = Range("A1", Range("A65536").End(xlUp))

For i = Range("E65536").End(xlUp).Row To 1 Step -1

into rows count?

SearchRange = Range("A1", Range("A65536").End(xlUp))

For i = Range("E65536").End(xlUp).

into rows count?

Your help has saved me hundreds of hours of internet surfing.

fblack61

Log in or sign up to see answer

Become an EE member today7-DAY FREE TRIAL

Members can start a 7-Day Free trial then enjoy unlimited access to the platform

or

Learn why we charge membership fees

We get it - no one likes a content blocker. Take one extra minute and find out why we block content.

Not exactly the question you had in mind?

Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.

ask a question
>> The problem with activesheet.rows.count is that for example in Excel 2010 it will give you a value of 1048576, so better would be Activesheet.usedrange.rows.count.

I assume that that is what Jagwarman wants - otherwise it's a very odd thing to have in Excel 2010.

I assume that that is what Jagwarman wants - otherwise it's a very odd thing to have in Excel 2010.

Well my point is that with activesheet.rows.count his search range will include most likely over a million blank rows, while withActivesheet.usedrange.rows.count the search range will be limited to the actual number of used rows.

SearchRange = Activesheet.Usedrange.Rows.Count

For i = SearchRange To 1 Step -1

Note that this could be compressed to

For i = Activesheet.Usedrange.Rows.Count To 1 Step -1

For i = SearchRange To 1 Step -1

Note that this could be compressed to

For i = Activesheet.Usedrange.Rows

Get an unlimited membership to EE for less than $4 a week.

Unlimited question asking, solutions, articles and more.

not sure why Martin but I can't get yours to to run I get type mismatch at this point

position = InStr(LCase(SearchRange(i, 1)), LCase(targetString))

position = InStr(LCase(SearchRange(i,

I'm sorry but I misread your original question and in my code SearchRange is a number (of rows) rather than a range, so my response to your question should have been.

SearchRange = Range("A1", Activesheet.usedrange.rows.count)

For i = Activesheet.usedrange.rows.count To 1 Step -1

SearchRange = Range("A1", Activesheet.usedrange.rows

For i = Activesheet.usedrange.rows

Martin I am now getting

Method 'Range' of object '_Global' failed

Phillip Burton's works for me so I am going to accept his solution

But thanks for trying

Method 'Range' of object '_Global' failed

Phillip Burton's works for me so I am going to accept his solution

But thanks for trying

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!

Walt Forbes

Open in new window