• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Why need to ReDim (Re Dimention) variables? ReDim Preserver? in which situations?

Dear Sir,

Please spread some light on ReDim statement. and ReDim Preserver statement ?

Why need to ReDim -or ReDim Preserve to variables?
What point should need to be in mind when Redim or Redim preserve?

As for just simple example, when we subtotal on any range, there are many rows include in original range as total in our main range and also at the end of range, Grand Total or Subrtotal , and that time LastRow variable need to change or need to ReDim if you further process that range with all total, subtotals, as many ways,

since, after added rows the lastrow variable hold old value of LastRow in it.
if you use LastRow variable again , may be oldvalue of lastrow can mess-up your next process.

so there are need to assign new value of lastrow.so can we apply ReDim there?
or any other method to assign new value to that variable ?

Hope there are found some deep understandable point from here about ReDim and In which situations we must Redim the variables?

Regards,

Chirag Raval
 
ReDim only applies to arrays, and is used to resize them before populating them. Adding the Preserve keyword means that all the data that is already in the array is maintained when the array is resized.
 
Dear Sir @Debaser,

Thank you for reply.

So with reference to my above thread, lastRow variable is AutoAdjus its last row number in variable?

But , when we require to access this range after subtotal on it, its always displayed first time used row number , we must re-set value of last row to access full range with all added total row in this range.

if we further process on subtotalled range with used of lastrow variable, then how to auto-adjust lastRow variable? is there we can use ReDim ?

I am confused there that how can LastRow variable take right row number after subtotal or added rows or columns in main range?

Regards,

Chirag Raval
 
LastRow is not an array and so has nothing at all to do with Redim. I'm afraid I have no idea what the rest of your question means.
 
Dear Sir @Debaser ,

Please Don't Afraid, That's just my thinking as options as learning process like any novice.

Point is, How can we apply /assign new last row number to Last row variable after subtotalled at 1 level & before apply 2nd level subtotal we must refresh / reassigned last row number to that variable.

So Can we use Redim for it or any other methods to assign current right value to this variable?

Regards,

Chirag Raval
 
Hi !

Any numeric variable like for the last row # has nothing to do
with ReDim statement as it is not an array !
And as all is well explained in ReDim VBA help …

And I often not ever need any variable for any last row #
with all the basics yet shown in your previous threads.

So instead of asking a generic too large question,
the better as always is to well present a technical point
with an accurate attachment accordingly …
 
Back
Top