I have a spreadsheet where all the data are kept and are pulling in certain data to different spreadsheet(in the same wb) where dates are in by the columns. For example if customer "A" has data for 4/11/10(column B) and 4/24/10(column C) then all the #s that are for 4/11/10 goes to column B and 4/24/10 to column C.
However, for some reason I can't sum up those data by the date if i do something like:
prevCustomer = ""
For i = CS_DATA_ROW_HEADER + 1 To wsData.UsedRange.Count
If Trim(wsData.Cells(i, 1).Value) <> "" Then
curCustomer = UCase(Trim(wsData.Cells(i, 9).Value))
curLDate = Trim(wsData.Cells(i, 7).Value)
If (curCustomer <> prevCustomer) And (curLDate <> prevLDate) Then
'For Enhancmed Customer LC
If (prevCustomer <> "") Then
curEnhancedCustomerLCCnt = curEnhancedCustomerLCCnt + 1
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 1).Value = "NET"
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 5).Value = accumlateAmt = curLDate
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 6).Value = accumlateAmt
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 7).Value = accumlateAmt
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 8).Value = accumlateAmt
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 9).Value = accumlateAmt
End If
curEnhancedCustomerLCCnt = curEnhancedCustomerLCCnt + 2
PMO_D = DateAdd("d", -24, Date)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 5).Value = DatePart("d", PMO_D)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 6).Value = DatePart("d", PMO_D + 1)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 7).Value = DatePart("d", PMO_D + 2)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 8).Value = DatePart("d", PMO_D + 3)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 9).Value = DatePart("d", PMO_D + 4)
accumlateAmt = wsData.Cells(i, 14).Value / 1000000
Else
accumlateAmt = accumlateAmt + wsData.Cells(i, 14).Value / 1000000
End If
It sums up all the data for the same customers but I only want to sum up data for the same customers for only the ones in the same column. How can I do that instead of having shown same info for all the columns?
However, for some reason I can't sum up those data by the date if i do something like:
prevCustomer = ""
For i = CS_DATA_ROW_HEADER + 1 To wsData.UsedRange.Count
If Trim(wsData.Cells(i, 1).Value) <> "" Then
curCustomer = UCase(Trim(wsData.Cells(i, 9).Value))
curLDate = Trim(wsData.Cells(i, 7).Value)
If (curCustomer <> prevCustomer) And (curLDate <> prevLDate) Then
'For Enhancmed Customer LC
If (prevCustomer <> "") Then
curEnhancedCustomerLCCnt = curEnhancedCustomerLCCnt + 1
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 1).Value = "NET"
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 5).Value = accumlateAmt = curLDate
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 6).Value = accumlateAmt
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 7).Value = accumlateAmt
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 8).Value = accumlateAmt
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 9).Value = accumlateAmt
End If
curEnhancedCustomerLCCnt = curEnhancedCustomerLCCnt + 2
PMO_D = DateAdd("d", -24, Date)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 5).Value = DatePart("d", PMO_D)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 6).Value = DatePart("d", PMO_D + 1)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 7).Value = DatePart("d", PMO_D + 2)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 8).Value = DatePart("d", PMO_D + 3)
wsEnhancedCustomerLC.Cells(curEnhancedCustomerLCCnt, 9).Value = DatePart("d", PMO_D + 4)
accumlateAmt = wsData.Cells(i, 14).Value / 1000000
Else
accumlateAmt = accumlateAmt + wsData.Cells(i, 14).Value / 1000000
End If
It sums up all the data for the same customers but I only want to sum up data for the same customers for only the ones in the same column. How can I do that instead of having shown same info for all the columns?