Hi All,
I'm looking to be able to create a macro that will sort ascending a variable amount of rows. The form, in order to get a picture of what it looks like, is comprised of a variable number of invoices, extracted into Excel ('03) from another system. Each invoice also contains a variable amount of rows.
Let's say the numbers I would like to sort ascending are in Column U and the macro will get to the first line in this grouping via cell referencing. In this case, let's say the first line is Row 7 and there are 5 rows in the first invoice. Therefore, using cell referencing, I would have to sort ascending the range of A1:A5 (without cell referencing, U7:U12).
My two questions are as follows:
1) How can I create this variable range (i.e.
ActiveCell.Range("A1:A5").Select
), when A5 is variable
2) How can I create the entire variable range of the area it will sort ascending with it, expanding the selection to the entire block I'm working with, which will also vary according to top and bottom rows, but not columns
I have screwed around with vRowBottom, vRowTop, vDiff=vRowBottom - vRowTop, and then referencing vDiff in the Range, but I'm not quite sure how to do this with sorting. If I was using a formula such as sum, it would look something like this:
Selection.FormulaR1C1 = "=SUM(R[" & -vDiff & "]C:R[-1]C)"
(just as an example).
Please let me know if anyone has any thoughts and if you have any questions or need me to provide any further information, just let me know.
Bookmarks