VBA Dynamic Selection

A

AJMorgan591

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 :)
 
G

Guest

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
 
T

Tom Ogilvy

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" <[email protected]>
wrote in message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top