NEED HELP - SUM Using VBA

hmchang82

New Member
Joined
May 26, 2010
Messages
13
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?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top