fraudit
New Member
- Joined
- Jan 14, 2015
- Messages
- 11
I've created a macro that's supposed to:
1. get the account numbers from another sheet, together with their transactions
2. de-duplicate account numbers
3. calculate the number their transactions, dependent on the transaction status (pass, review, reject)
4. allocate customers to the sales channels (online, offline, telesales and if more than one - multi)
The macro works almost correctly - when the file is small, it runs perfectly, but when the file gets bigger (approx 100k transactions), I'm only getting a couple of hundreds of rows correctly prepopulated and the remaining values are zeros.
I believe then the next function runs before the previous one had the chance to complete and hence those zeros...
Can you advise me what to do in order to make all the embedded functions be able to produce all result?
Here's the relevant part of the code:
1. get the account numbers from another sheet, together with their transactions
2. de-duplicate account numbers
3. calculate the number their transactions, dependent on the transaction status (pass, review, reject)
4. allocate customers to the sales channels (online, offline, telesales and if more than one - multi)
The macro works almost correctly - when the file is small, it runs perfectly, but when the file gets bigger (approx 100k transactions), I'm only getting a couple of hundreds of rows correctly prepopulated and the remaining values are zeros.
I believe then the next function runs before the previous one had the chance to complete and hence those zeros...
Can you advise me what to do in order to make all the embedded functions be able to produce all result?
Here's the relevant part of the code:
Code:
' DE-DUPLICATE CUSTOMERS
Dim LastUndupedRow As Long
LastUndupedRow = ActiveSheet.UsedRange.Rows.Count
Range("A1:A" & LastUndupedRow).RemoveDuplicates Columns:=1, Header:=xlYes
' CHECK STATUSES
Dim LastRow As String
LastRow = ActiveSheet.UsedRange.Rows.Count
Range("B2:B" & LastRow).FormulaR1C1 = _
"=COUNTIFS(TMX_Data!C15,Customers_Stats!RC1,TMX_Data!C9,""pass"")"
Range("C2:C" & LastRow).FormulaR1C1 = _
"=COUNTIFS(TMX_Data!C15,Customers_Stats!RC1,TMX_Data!C9,""review"")"
Range("D2:D" & LastRow).FormulaR1C1 = _
"=COUNTIFS(TMX_Data!C15,Customers_Stats!RC1,TMX_Data!C9,""reject"")"
Range("E2:E" & LastRow).FormulaR1C1 = _
"=IF(RC[-3]>0,""pass"",IF(RC[-2]>0,""pass"",""reject""))"
Range("F2:F" & LastRow).FormulaR1C1 = _
"=COUNTIFS(TMX_Data!C15,Customers_Stats!RC1,TMX_Data!C27,""default"")"
Range("G2:G" & LastRow).FormulaR1C1 = _
"=COUNTIFS(TMX_Data!C15,Customers_Stats!RC1,TMX_Data!C27,""offline"")"
Range("H2:H" & LastRow).FormulaR1C1 = _
"=COUNTIFS(TMX_Data!C15,Customers_Stats!RC1,TMX_Data!C27,""telesales"")"
Range("I2:I" & LastRow).FormulaR1C1 = _
"=COUNTIFS(TMX_Data!C15,Customers_Stats!RC1,TMX_Data!C27,""test"")"
Range("J2:J" & LastRow).FormulaR1C1 = _
"=IF(OR(AND(RC6>0,RC7>0),AND(RC6>0,RC8>0),AND(RC7>0,RC8>0)),""multi"",(IF(AND(RC6>0,RC7=0,RC8=0),""online"",(IF(AND(RC6=0,RC7>0,RC8=0),""offline"",""telesales"")))))"
With Range("B2:J" & LastRow)
.Value = Range("B2:J" & LastRow).Value
.HorizontalAlignment = xlCenter
.ColumnWidth = 10#
End With