rudolphc83
New Member
- Joined
- May 7, 2018
- Messages
- 3
Hi Guys
I'm new here and I have been searching for hours, so please forgive me if there is a thread for this already.
I have a data file, approx 20k line items that I need to report on. From this data certain line items needs to be copied to other worksheets in the same workbook based on certain criteria. The code I am currently using works fine but it's crazy slow due to it being a loop based macro. What I need to do is get the same result but with something a little more lightweight. Could you please help?
Here is the code I currently use, it is only a part of the entire code, but the idea is still there:
Thanks for the help guys
I'm new here and I have been searching for hours, so please forgive me if there is a thread for this already.
I have a data file, approx 20k line items that I need to report on. From this data certain line items needs to be copied to other worksheets in the same workbook based on certain criteria. The code I am currently using works fine but it's crazy slow due to it being a loop based macro. What I need to do is get the same result but with something a little more lightweight. Could you please help?
Here is the code I currently use, it is only a part of the entire code, but the idea is still there:
Code:
Sub SplitData()
Worksheets("Open OBD").Activate
Dim lr As Long, lr2 As Long, lr3 As Long, Lr4 As Long, lr5 As Long, r As Long
lr = Sheets("Open OBD").Cells(Rows.Count, "A").End(xlUp).Row
lr2 = Sheets("PAN003 NON-ECC").Cells(Rows.Count, "A").End(xlUp).Row
lr3 = Sheets("PAN003 INT").Cells(Rows.Count, "A").End(xlUp).Row
Lr4 = Sheets("Not in PP").Cells(Rows.Count, "A").End(xlUp).Row
lr5 = Sheets("PANBCT DOM").Cells(Rows.Count, "A").End(xlUp).Row
For r = lr To 2 Step -1
Select Case Range("N" & r).Value
Case Is = "Not Processed"
Rows(r).Copy
With Sheets("Not in PP").Range("A" & Lr4 + 1)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
Lr4 = Sheets("Not in PP").Cells(Rows.Count, "A").End(xlUp).Row
End With
End Select
Select Case Range("W" & r).Value
Case Is = "NO"
Rows(r).Copy
With Sheets("PAN003 NON-ECC").Range("A" & lr2 + 1)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
lr2 = Sheets("PAN003 NON-ECC").Cells(Rows.Count, "A").End(xlUp).Row
End With
End Select
Next r
End Sub
Thanks for the help guys
Last edited by a moderator: