I need a message displayed in the status bar. I have written the below code. It is freezing Excel after displaying up to 300+.
The main sheet has 20K+ data and copying is taking around 10 minutes.
It will be good if the status bar can show it.
I thought of using a Progress Bar, but it will also freeze.
Sub Split_Consolidate_Data()
Call Delet_Split_Consolidated_Old_Date
Dim xRange1 As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = ActiveWorkbook.Worksheets("Consolidated Data").UsedRange.rows.Count
Set xRange1 = ActiveWorkbook.Worksheets("Consolidated Data").Range("AA2:AA" & I)
J = 1
L = 1
M = 1
n = 1
O = 1
P = 1
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRange1.Count
Application.StatusBar = "Copying " & K & ""
If (CStr(xRange1(K).Value) = 1) Then
xRange1(K).EntireRow.Copy Destination:=Worksheets("Week 1").Range("A" & J + 1)
J = J + 1
ElseIf (CStr(xRange1(K).Value) = 2) Then
xRange1(K).EntireRow.Copy Destination:=Worksheets("Week 2").Range("A" & L + 1)
L = L + 1
ElseIf (CStr(xRange1(K).Value) = 3) Then
xRange1(K).EntireRow.Copy Destination:=Worksheets("Week 3").Range("A" & M + 1)
M = M + 1
ElseIf (CStr(xRange1(K).Value) = 4) Then
xRange1(K).EntireRow.Copy Destination:=Worksheets("Week 4").Range("A" & n + 1)
n = n + 1
ElseIf (CStr(xRange1(K).Value) = 5) Then
xRange1(K).EntireRow.Copy Destination:=Worksheets("Week 5").Range("A" & O + 1)
O = O + 1
ElseIf (CStr(xRange1(K).Value) = 6) Then
xRange1(K).EntireRow.Copy Destination:=Worksheets("Week 6").Range("A" & P + 1)
P = P + 1
End If
Next
Application.ScreenUpdating = True
End Sub
How can I get rid of the freeze or is there any other way I can see how much has processed?