More VBA Help please

  • Thread starter Thread starter Malcolm Hind
  • Start date Start date
M

Malcolm Hind

I can use this code;

ActiveSheet.UsedRange.Cells.Select
MsgBox ActiveSheet.UsedRange.Cells.Address

and the message gives $A$1:$E$8 - which is correct

Can I parse out (or programatically get) the Start ($A$1) and End ($E$8)
Address values ?

How would I (for instance) Set a Range to those values ?

Can I further parse out the actual Row/Column Elements (giving me 4 seperate
values) so I could reconstruct a new Range with calculated & actual values ?

Not used to working with vba too much so trying to get a grip on how things
work.

Thanks for any help
 
This might be a bit complex for you, but I find it the easiest way to
handle individual values (ergo 'elements') of a range of value/data...

Dim vDataIn, n&, k&
vDataIn = ActiveSheet.UsedRange
For n = 1 to UBound(vDataIn) '//iterate each row
For k = 1 To UBound(vDataIn, 2) '//iterate each col
Debug.Print vDataIn(n, k) '//do stuff with each element
Next 'k
Next 'n

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
GS said:
This might be a bit complex for you, but I find it the easiest way to
handle individual values (ergo 'elements') of a range of value/data...

Dim vDataIn, n&, k&
vDataIn = ActiveSheet.UsedRange
For n = 1 to UBound(vDataIn) '//iterate each row
For k = 1 To UBound(vDataIn, 2) '//iterate each col
Debug.Print vDataIn(n, k) '//do stuff with each element
Next 'k
Next 'n

Thanks Ron and to you GS,

I again have a couple of follow ups that I will post seperately.

Thanks for the help
 
Back
Top