Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Dynamic Selection


Hi all,

Long story short, is it possible in VBA to dynamically select cells in
the range (for example) A1:Mx where x = the last row that contains data
(i.e. non-blank cells). The blank cells (i.e. those cells after row x)
do contain formulas linked to other worksheets but if the relevant
cells in those other worksheets are blank then so too are these cells.

Thanks in advance :)


--
AJMorgan591
------------------------------------------------------------------------
AJMorgan591's Profile: http://www.excelforum.com/member.php...o&userid=27774
View this thread: http://www.excelforum.com/showthread...hreadid=473647

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default VBA Dynamic Selection


sub LastCellColM

Dim rngLastCell as Range
Dim MyRange as Range

Set rngLastCell = Range("M65536").End(xlUp)
Set MyRange = Range("A1", rngLastCell)

' do your thing

end sub



"AJMorgan591" wrote:


Hi all,

Long story short, is it possible in VBA to dynamically select cells in
the range (for example) A1:Mx where x = the last row that contains data
(i.e. non-blank cells). The blank cells (i.e. those cells after row x)
do contain formulas linked to other worksheets but if the relevant
cells in those other worksheets are blank then so too are these cells.

Thanks in advance :)


--
AJMorgan591
------------------------------------------------------------------------
AJMorgan591's Profile: http://www.excelforum.com/member.php...o&userid=27774
View this thread: http://www.excelforum.com/showthread...hreadid=473647


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA Dynamic Selection

A lot would depend on what is in the non-empty cells. If the formulas
return either a number or an empty string, then you could use special cells
to only go to the numbers, but if the formulas might return text as well,
then I think you would need to loop through them to determine where the last
cell is located that contains real data. Any method such as specialcells
or the end(xlup) as suggested by Cush, would see any cell with a formula as
containing data whether it appeared blank or not.

--
Regards,
Tom Ogilvy



"AJMorgan591"
wrote in message
...

Hi all,

Long story short, is it possible in VBA to dynamically select cells in
the range (for example) A1:Mx where x = the last row that contains data
(i.e. non-blank cells). The blank cells (i.e. those cells after row x)
do contain formulas linked to other worksheets but if the relevant
cells in those other worksheets are blank then so too are these cells.

Thanks in advance :)


--
AJMorgan591
------------------------------------------------------------------------
AJMorgan591's Profile:

http://www.excelforum.com/member.php...o&userid=27774
View this thread: http://www.excelforum.com/showthread...hreadid=473647



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
Dynamic Range Selection Using VBA TEK Excel Discussion (Misc queries) 2 January 23rd 10 04:55 AM
SUBTOTAL - dynamic selection Totteridge Ram Excel Worksheet Functions 3 December 17th 08 01:09 AM
dynamic selection of cells parthaemail New Users to Excel 1 April 25th 06 12:13 PM
Dynamic Range Selection Todd Huttenstine Excel Programming 4 May 5th 04 08:54 PM
Dynamic Row Selection Bruce B[_2_] Excel Programming 4 July 14th 03 09:14 PM


All times are GMT +1. The time now is 11:15 AM.

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"