Subtotals in VBA
Posted on 2009-12-18
I'm trying to create a macro via VBA to copy my data from one tab to another and subtotal it. What I want to copy is columns A, B, C, D, E & G and then subtotal that by column A and then also give me totals (sum) for columns C & D. My headers are in row 3 and I also want to copy those as well. The amount of rows will vary in this tab since the data is updated monthly so I'm hoping it can be written to copy all rows of data. I also want to be able to specify which rows to copy based on the value in column A. This can be hard-coded into the VBA code and if it was to change I could just modify it as needed.
Example of the rows to specify from column A: "416SS", "416", "303SS"
So this would be hard-coded in the VBA code and I could add or delete to these values.
The values in Column A are formatted as general because they are a combination of numbers and text.
So I want to get a subtotals for columns C & D on this new tab it creates and have it also show the value it subtotalled in Column A along with the word "Total".
For example column A has a value of 416SS so on the subtotal tab it would say "416SS Total".
I'm very new to VBA so that's why I'm here. I'm hoping someone can help me write this code.