Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
AMK
 
Posts: n/a
Default variable range in a macro

I have a worksheet where the number of rows and columns vary each time I
process the data.
I want to transpose the cols and rows but need to set the range before I
copy. There may not be any data in the XY cell. Is there a way to do this in
a macro?
Thanks for any help.
--
Al
  #2   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Al,

Assume data starts in A1 and that there is a blank row below, and a blank
column to the right, of the data, then your data can be defined by:

ActiveSheet.Range("A1").CurrentRegion

---
Regards,
Norman



"AMK" wrote in message
...
I have a worksheet where the number of rows and columns vary each time I
process the data.
I want to transpose the cols and rows but need to set the range before I
copy. There may not be any data in the XY cell. Is there a way to do this
in
a macro?
Thanks for any help.
--
Al



  #3   Report Post  
\VoG via OfficeKB.com\
 
Posts: n/a
Default

LastRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row

LastCol = Cells(1, 256).End(xlToLeft)

--
Message posted via http://www.officekb.com
  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

or being consistent

LastCol = Cells(1, Columns.Count).End(xlToLeft).Column

--
HTH

Bob Phillips

""VoG via OfficeKB.com"" wrote in message
...
LastRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row

LastCol = Cells(1, 256).End(xlToLeft)

--
Message posted via http://www.officekb.com



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
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
Print range macro nc Excel Discussion (Misc queries) 3 March 21st 05 04:38 PM
automatic macro update boconnell Excel Worksheet Functions 4 February 9th 05 07:10 PM
How do I set a date range for conditional formatting in a macro? billo Excel Worksheet Functions 3 February 7th 05 06:19 PM
empty variable range S1 Excel Discussion (Misc queries) 5 January 28th 05 02:33 PM


All times are GMT +1. The time now is 09:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"