I need a modified version of this code which can call a macro in it.
--------------------------------------------------------------------------------
Sub example_1()
Dim rng As Range, i As Long, clnrng As Range
Set clnrng = Range("a1:a10000"
i = 0
With Prog_bar
'SET MIN value to 0
.ProgressBar1.Min = 0
'SET Max value equal to cells count
.ProgressBar1.Max = clnrng.Cells.Count
.Show vbModeless
End With
For Each rng In clnrng.Cells
' do clean and trim using vba
rng.Value = Application.WorksheetFunction.Clean(Application.WorksheetFunction.Trim(rng.Value))
i = i + 1
'change the value of progress bar to show the progress using fill color
Prog_bar.ProgressBar1.Value = i
' chnage the caption of user form to display the percentage of task completed
Prog_bar.Caption = VBA.Format(i / Prog_bar.ProgressBar1.Max, "0%"
& " Complete"
DoEvents ' DoEvents allows the UserForm to update.
Next
' task finish unload progress bar
Unload Prog_bar
End Sub
-----------------------------------------------------------------------------------
This is the macro i want to call inside above code
-----------------------------------------------------------------------------------
Public Sub Copy_supply_Data()
' Dim Customer_Name As String
' Dim Start_Date As Date
' Dim End_Date As Date
' Dim Additional_Criterion As String
' With Sheets("Dashboard"
' Customer_Name = .Range("A21"
.Value
' Start_Date = .Range("D21"
.Value
' End_Date = .Range("E21"
.Value
' Additional_Criterion = .Range("G21"
.Value
' End With
' By declaring an array , the above statements are replaced by the following two statements
' Customer_name is Record_Array(1,1)
' Start_Date is Record_Array(1,4)
' End_Date is Record_Array(1,5)
' Additional_Criterion is Record_Array(1,7)
Application.ScreenUpdating = False
Dim Copy_From_Sheet As Worksheet
Dim Paste_To_Sheet As Worksheet
Dim Row_Array As Variant
Dim Record_Array As Variant
Record_Array = ThisWorkbook.Worksheets("Dashboard"
.Range("A21:G21"
.Value
Set Copy_From_Sheet = ThisWorkbook.Worksheets("Supply Data"
Set Paste_To_Sheet = ThisWorkbook.Worksheets("supply filtered data"
Paste_To_Sheet.Activate
Application.ScreenUpdating = True
user_input = MsgBox("Do you wish to APPEND to earlier data ( Y/N ) ; NO means earlier data will be overwritten !", vbYesNo)
If user_input = vbYes Then
ActiveSheet.Cells(ActiveSheet.Rows.Count, "A"
.End(xlUp).Offset(1, 0).Select
Else
ActiveSheet.Range("A2", ActiveSheet.Range("A2"
.End(xlDown)).EntireRow.ClearContents
ActiveSheet.Range("A2"
.Select
End If
Application.ScreenUpdating = False
Copy_From_Sheet.Activate
ActiveSheet.Range("Supply_Data"
.Select
Number_of_rows = Selection.Rows.Count
Number_of_columns = Selection.Columns.Count
row_counter = 0
For I = 1 To Number_of_rows
Row_Array = Selection.Cells(1, 1).Offset(I - 1, 0).Resize(1, Number_of_columns).Value
Customer_Name = Row_Array(1, 1)
Check_Date = Row_Array(1, 9)
Additional_Check = Row_Array(1, 11)
If Customer_Name = Record_Array(1, 1) Then
If ((Check_Date >= Record_Array(1, 4)) And (Check_Date <= Record_Array(1, 5))) Then
If ((Record_Array(1, 7) = ""
Or (Additional_Check = Record_Array(1, 7))) Then
Paste_To_Sheet.Activate
ActiveCell.Offset(row_counter, 0).Resize(1, Number_of_columns).Value = Row_Array
row_counter = row_counter + 1
Copy_From_Sheet.Activate
End If
End If
End If
Next
Application.ScreenUpdating = True
If row_counter > 0 Then
MsgBox "Procedure Over , " & Str(row_counter) & " records copied / pasted"
End If
End Sub
-----------------------------------------------------------------------------------