Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ray ray is offline
external usenet poster
 
Posts: 3
Default Return Range in VB

This is going to be a noobie type question, but I really need some help. I
want to be able to determine the range of cells that are populated with
values(ie A4:E20) using VB. I will then take this range, copy it and paste
it transposed to another sheet. I have the second part done, just can't
quite get the part about returning the range on a sheet dynamically based
on the cells with values. The sheet will be updated regularly and I don't
want to have to change the code for the populated range each time.

I hope this makes sense.

Thanks
Ray
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Return Range in VB

Unless the populated cells are a contiguous rectangle, you won't be able to
paste transposed

set rng = Range("A4:E20").SpecialCells(xlConstants)

--
Regards,
Tom Ogilvy

"ray" wrote in message
.. .
This is going to be a noobie type question, but I really need some help. I
want to be able to determine the range of cells that are populated with
values(ie A4:E20) using VB. I will then take this range, copy it and paste
it transposed to another sheet. I have the second part done, just can't
quite get the part about returning the range on a sheet dynamically based
on the cells with values. The sheet will be updated regularly and I don't
want to have to change the code for the populated range each time.

I hope this makes sense.

Thanks
Ray



  #3   Report Post  
Posted to microsoft.public.excel.programming
ray ray is offline
external usenet poster
 
Posts: 3
Default Return Range in VB

"Tom Ogilvy" wrote in
:

Unless the populated cells are a contiguous rectangle, you won't be
able to paste transposed

set rng = Range("A4:E20").SpecialCells(xlConstants)


They are a contiguos rectangle. The range will only grow in number of rows,
not columns. Just need to be able to have a routine that always starts in a
cell and then determines the end of range based on occupied cells.

Date Data1 Data2 Data3
1103 1 2 3
2103 4 5 6

Assuming the data(minus headings) starts in A2, then the range of this
would be A2:D3. I need a routine to automagically determine that.

Ray
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Return Range in VB

If it is always going to be A to D and start in Row 2, why cite A4 to E20 in
your original post?

Nonetheless,

set rng = Range(Range("A2"),Range(A21).End(xlup)).Resize(,4)

--
Regards,
Tom Ogilvy

"ray" wrote in message
...
"Tom Ogilvy" wrote in
:

Unless the populated cells are a contiguous rectangle, you won't be
able to paste transposed

set rng = Range("A4:E20").SpecialCells(xlConstants)


They are a contiguos rectangle. The range will only grow in number of

rows,
not columns. Just need to be able to have a routine that always starts in

a
cell and then determines the end of range based on occupied cells.

Date Data1 Data2 Data3
1103 1 2 3
2103 4 5 6

Assuming the data(minus headings) starts in A2, then the range of this
would be A2:D3. I need a routine to automagically determine that.

Ray



  #5   Report Post  
Posted to microsoft.public.excel.programming
ray ray is offline
external usenet poster
 
Posts: 3
Default Return Range in VB

"Tom Ogilvy" wrote in
:

If it is always going to be A to D and start in Row 2, why cite A4 to
E20 in your original post?

Nonetheless,

set rng = Range(Range("A2"),Range(A21).End(xlup)).Resize(,4)


Because I lost track of my example. Should have been A to E as indicated in
original post. Thanks

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
Return date if in range, else return blank LisaL Excel Worksheet Functions 1 July 22nd 09 03:23 PM
if range b6:n6 has no content, return A6 Twishlist Excel Worksheet Functions 7 January 25th 08 03:34 AM
return min. of range except 0 Melissa Excel Discussion (Misc queries) 2 January 11th 06 12:14 PM
return a value based on a range Michael NYC Excel Worksheet Functions 3 September 28th 05 05:49 PM
How do I return the name of a Range? **Archie** Excel Programming 1 November 13th 03 11:31 PM


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