HiAspire
Technical User
- Oct 17, 2002
- 10
I have written a few macros in Office 2000 but I've gotten stuck on a macro I'm using to generate invoices.
I need it to do some basic mathmatics for me from a dynamic table that can be various rows long depending on user clicks. Easy enough with an established set table referencing known cells using commands like cell A2 times cell B2, or = sum(Table1 c:c).
QTY PRICE TOTAL
2 1.50 3.00
4 2.00 8.00
11.00
But what about when you don't know how many rows are going to be in a dynamic table that's created one row at a time (including the right total collumn) by user clicks and not fixed where you can say cell a2 but instead need to say the current value of cell A at whatever the current row is, like a4 or a5 or a6 depending.
This is an oversimplification because there are many more collumns involved. Can you determine the current row and use that in the total formula?
Or can you say something like "multiply the cell 4 collumns to the left, by the cell 2 collumns to the left"? So that you don't have to worry about the row number at all? I know you can do some things like that with other commands like sum(LEFT). Can I create a variable to keep track of how many rows are being used and somehow incorporate that number into the cell reference (if that variable equals 4, then use A4)? What is the best way to do this?
Hopefully I'm over-thinking it and missing something simple. Thank for your help.
I need it to do some basic mathmatics for me from a dynamic table that can be various rows long depending on user clicks. Easy enough with an established set table referencing known cells using commands like cell A2 times cell B2, or = sum(Table1 c:c).
QTY PRICE TOTAL
2 1.50 3.00
4 2.00 8.00
11.00
But what about when you don't know how many rows are going to be in a dynamic table that's created one row at a time (including the right total collumn) by user clicks and not fixed where you can say cell a2 but instead need to say the current value of cell A at whatever the current row is, like a4 or a5 or a6 depending.
This is an oversimplification because there are many more collumns involved. Can you determine the current row and use that in the total formula?
Or can you say something like "multiply the cell 4 collumns to the left, by the cell 2 collumns to the left"? So that you don't have to worry about the row number at all? I know you can do some things like that with other commands like sum(LEFT). Can I create a variable to keep track of how many rows are being used and somehow incorporate that number into the cell reference (if that variable equals 4, then use A4)? What is the best way to do this?
Hopefully I'm over-thinking it and missing something simple. Thank for your help.