Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Selecting range problem

Hi to all

I use the following line to select a range of values.

ActiveSheet.Range("A1:C" & ActiveSheet.Range("A1").End(xlDown).Row).Select

The problem is that I want to go down to the last row with actual values,
not formulas that produce a blank. For example, A1:A100 has the formula
=IF(J1="","",SQRT(J1)), dragged down, but there may be values only in
A1:A30. I'd like the code to select A1:C30, not A1:C100. Contiguous,
non-blank values only.

TQ for any clues, Dorre




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting range problem

I think I'd just start at the top and loop through each cell looking for the
first cell that evaluated to "".

dim LastCell as range
set lastcell = activesheet.range("a1")
do
if lastcell.value = "" then
exit do
else
set lastcell = lastcell.offset(1,0)
end if
loop

range("a1:c" & lastcell.row).select



dorre wrote:

Hi to all

I use the following line to select a range of values.

ActiveSheet.Range("A1:C" & ActiveSheet.Range("A1").End(xlDown).Row).Select

The problem is that I want to go down to the last row with actual values,
not formulas that produce a blank. For example, A1:A100 has the formula
=IF(J1="","",SQRT(J1)), dragged down, but there may be values only in
A1:A30. I'd like the code to select A1:C30, not A1:C100. Contiguous,
non-blank values only.

TQ for any clues, Dorre


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Selecting range problem

excellent advice
dorre

"Dave Peterson" wrote in message
...
I think I'd just start at the top and loop through each cell looking for
the
first cell that evaluated to "".

dim LastCell as range
set lastcell = activesheet.range("a1")
do
if lastcell.value = "" then
exit do
else
set lastcell = lastcell.offset(1,0)
end if
loop

range("a1:c" & lastcell.row).select



dorre wrote:

Hi to all

I use the following line to select a range of values.

ActiveSheet.Range("A1:C" &
ActiveSheet.Range("A1").End(xlDown).Row).Select

The problem is that I want to go down to the last row with actual values,
not formulas that produce a blank. For example, A1:A100 has the formula
=IF(J1="","",SQRT(J1)), dragged down, but there may be values only in
A1:A30. I'd like the code to select A1:C30, not A1:C100. Contiguous,
non-blank values only.

TQ for any clues, Dorre


--

Dave Peterson



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
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Help please in selecting range dependent on another range MickJJ Excel Programming 2 January 10th 05 12:01 PM
Problem selecting a named range kkknie[_180_] Excel Programming 0 August 11th 04 08:30 PM
Selecting a Range inside a range hcova Excel Programming 0 July 13th 04 03:26 PM
Problem selecting a range to print... usa1 Excel Programming 3 June 16th 04 01:07 AM


All times are GMT +1. The time now is 02:30 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"