Solved

is there a better way of saying

Posted on 2014-11-21
10
48 Views
Last Modified: 2014-11-23
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
0
Comment
Question by:Jagwarman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40457383
Instead of 65536 use:

activesheet.rows.count

Open in new window

0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40457518
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.
0
 

Author Comment

by:Jagwarman
ID: 40457533
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?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40457553
SearchRange = Range("A1", Range("A" & activesheet.rows.count).End(xlUp))
For i = Range("E" & activesheet.rows.count).End(xlUp).Row To 1 Step -1

Open in new window

0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40457555
>> 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.
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40457608
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.
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40457621
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
0
 

Author Comment

by:Jagwarman
ID: 40457742
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))
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40457774
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
0
 

Author Comment

by:Jagwarman
ID: 40457846
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
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question