I have created a macro that produces between 20 and 40 sheets of data depending on the source data and the sheets are named with a town and then either list or labels. eg "ipswich labels" then "ipswich list" then "norwich lables" "norwich list" etc continuing through many different towns. Each sheet called labels contains numeric data in column A. The heading at the top of column A is labelled QTY. The first 7 pages of the workbook contain other information so I am hoping that the For statement is correctly telling the system to count from worksheet 8 onwards.
After the macro has created the various sheets I would like to create a summary page called Totals which in column A puts the sheet name and in column b puts the total of the numeric data in column A, so that I have a list of all the towns and the total number allocated to that town. eg in A1 ipswich in B1 323, in A2 norwich in B2 221 etc
I have not yet tried to bring over the sheet name, but firstly I was trying to get a macro to loop through the various pages to do an autosum on column A and put that value on the Totals Page, (I do not need the total on the individual pages) but I am having problems trying to get the macro to move through the different pages. The line which is causing problems is the If Line as I cannot work out how to tell it to go to the correct place on the first sheet it comes across.
I would be grateful for any help to point me on the way and if there is a way to bring over the sheet name as well I would be really delighted.
Many, many thanks in advance
Sub Totals()
Dim worksheetcount As Integer
Dim WS As Worksheet
Dim rw As Long
rw = Range("A65536").End(xlUp).row
Sheets("Totals").Activate
Range("B2").Select
For worksheetcount = 8 To Worksheets.Count
If WS.Range(R1c1) = "QTY" Then
ActiveCell.FormulaR1C1 = "=sum(activesheet!r2c1:rw&c1)"
Rows(row).Offset(1, 0).Select
Else
End If
Next worksheetcount
End Sub
After the macro has created the various sheets I would like to create a summary page called Totals which in column A puts the sheet name and in column b puts the total of the numeric data in column A, so that I have a list of all the towns and the total number allocated to that town. eg in A1 ipswich in B1 323, in A2 norwich in B2 221 etc
I have not yet tried to bring over the sheet name, but firstly I was trying to get a macro to loop through the various pages to do an autosum on column A and put that value on the Totals Page, (I do not need the total on the individual pages) but I am having problems trying to get the macro to move through the different pages. The line which is causing problems is the If Line as I cannot work out how to tell it to go to the correct place on the first sheet it comes across.
I would be grateful for any help to point me on the way and if there is a way to bring over the sheet name as well I would be really delighted.
Many, many thanks in advance
Sub Totals()
Dim worksheetcount As Integer
Dim WS As Worksheet
Dim rw As Long
rw = Range("A65536").End(xlUp).row
Sheets("Totals").Activate
Range("B2").Select
For worksheetcount = 8 To Worksheets.Count
If WS.Range(R1c1) = "QTY" Then
ActiveCell.FormulaR1C1 = "=sum(activesheet!r2c1:rw&c1)"
Rows(row).Offset(1, 0).Select
Else
End If
Next worksheetcount
End Sub