Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub Summary_calculation()
- Dim wb As Workbook
- Dim ws As Worksheet
- Dim endrow As Integer
- Dim temprow As Integer
- Dim tempcol As Integer
- Dim i As Integer
- Dim totalrec As Integer
- Dim tmpSheet As Worksheet
- Dim SKUCol As Integer
- Dim SKUName As String
- Dim tmpSheetrow As Integer
- Dim tmpcol As Integer
- Dim tmpQty As Double
- Set wb = ActiveWorkbook
- Set ws = wb.Sheets("Summary")
- SKUCol = 3
- totalrec = ws.Cells(startrow, 1).CurrentRegion.Rows.Count - 1
- For i = 1 To totalrec
- SKUName = ws.Cells(i + startrow, SKUCol).Value
- Set tmpSheet = wb.Sheets(SKUName)
- 'tmpSheet.Activate (Got 1004 error whenever remove this line of code)
- tmpSheetrow = tmpSheet.Cells(startrow, Gapcol).CurrentRegion.Rows.Count + startrow - 1
- For tmpcol = 0 To 16
- With wb.Sheets(SKUName)
- ws.Cells(i + startrow, tmpcol + 4).Value = Application.WorksheetFunction.Sum(.Range(Cells(startrow + 1, PropStartcol + tmpcol), Cells(tmpSheetrow, PropStartcol + tmpcol)))
- End With
- Next tmpcol
- ws.Cells(1, 10) = Format(i / totalrec, "00%")
- DoEvents
- Next i
- End Sub
Add Comment
Please, Sign In to add comment