Hi all
I have code belove in sheets(A) and work well
Now i want appear progress bar like this whrn run code:
Please help me.
I have code belove in sheets(A) and work well
Code:
Private Sub Worksheet_Change(ByVal Target As Range)Dim rngB As Range, rngC As Range, cel As Range
Dim wksB As Worksheet, wksC As Worksheet, wksD As Worksheet
Dim lngRowB As Long, lngRowC As Long, lngRowD As Long, lngRowsCopied As Long
If Target.Address = "$A$1" Then
If Len(Trim(Target.Value)) = 4 Then
Set wksB = ThisWorkbook.Worksheets("B")
Set wksC = ThisWorkbook.Worksheets("C")
Set wksD = ThisWorkbook.Worksheets("D")
wksD.Cells.Clear
lngRowB = wksB.Range("A" & Rows.Count).End(xlUp).Row
lngRowC = wksC.Range("A" & Rows.Count).End(xlUp).Row
lngRowD = wksD.Range("A" & Rows.Count).End(xlUp).Row
Set rngB = wksB.Range("A1:A" & lngRowB)
Set rngC = wksC.Range("A1:A" & lngRowC)
lngRowsCopied = 0
For Each cel In rngB
If InStr(1, "-" & cel.Value, Target.Value, vbTextCompare) > 0 Then
lngRowD = lngRowD + 1
cel.EntireRow.Copy Destination:=wksD.Cells(lngRowD, 1)
lngRowsCopied = lngRowsCopied + 1
End If
Application.StatusBar = "Processing sheet B: " & Format(cel.Row / rngB.Rows.Count, "0%") & " Rows copied = " & lngRowsCopied
Next cel
lngRowsCopied = 0
For Each cel In rngC
If InStr(1, "-" & cel.Value, Target.Value, vbTextCompare) > 0 Then
lngRowD = lngRowD + 1
cel.EntireRow.Copy Destination:=wksD.Cells(lngRowD, 1)
lngRowsCopied = lngRowsCopied + 1
End If
Application.StatusBar = "Processing sheet C: " & Format(cel.Row / rngC.Rows.Count, "0%") & " Rows copied = " & lngRowsCopied
Next cel
Else
MsgBox ("Enter a valid 4-digit year.")
End If
End If
Application.StatusBar = False
End Sub
Now i want appear progress bar like this whrn run code:
Please help me.