Please can someone help me input this progress indictor into my macro

tonylpcs@yahoo.co.uk

Active Member
Joined
Dec 19, 2007
Messages
379
Hi Everyone,

I have recived some help from you all that has alowed me to follow simple instruction on the site bellow and i have managed to recreate the example they give perfectly , http://spreadsheetpage.com/index.php/site/tip/displaying_a_progress_indicator/
however i cant work out how to combine the code in there module listed below into my module code list below also so i get the progress bar to work fo my macro not send loads of random numbers everywhere.
my macro takes about 20 seconds to run so even if there was a timer in there that counts down would be fine i just want it to work, any of you code geniuses out there able to help me? please!

thanks

Tony

(there code that is used to put random numbers on a sheet whilst showing the progress bar is below)

HTML:
Sub Main()
'   Inserts random numbers on the active worksheet
    Dim Counter As Integer
    Dim RowMax As Integer, ColMax As Integer
    Dim r As Integer, c As Integer
    Dim PctDone As Single
    
    If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
    Cells.Clear
    Application.ScreenUpdating = False
    Counter = 1
    RowMax = 100
    ColMax = 25
    For r = 1 To RowMax
        For c = 1 To ColMax
            Cells(r, c) = Int(Rnd * 1000)
            Counter = Counter + 1
        Next c
        PctDone = Counter / (RowMax * ColMax)
        With UserForm1
            .FrameProgress.Caption = Format(PctDone, "0%")
            .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
        End With
'       The DoEvents statement is responsible for the form updating
        DoEvents
    Next r
    Unload UserForm1
End Sub

and my macro that i use on my spreedsheet that i want the progress bar to show when running is:

HTML:
Sub PrintIt()
    Application.ScreenUpdating = False
    If WorksheetFunction.CountA(Sheets("Sheet1").Range("E5,E7,E9,E11,E13,E17,E21,E23,E25,E27,K9,K11,K15,K19,K21,K23,K25,K27,K29,K31,K35")) <> 21 Then
    MsgBox "All white cells must be completed, if no data plese input a zero", vbExclamation
    Exit Sub
End If
    Dim Answer As VbMsgBoxResult
    Answer = MsgBox("Are you sure you want to print? all data will be transfered if you click yes?", vbYesNo)
    If Answer = vbNo Then Exit Sub
'   Your print code

Application.EnableEvents = False
Dim msg As String
With ActiveSheet
   .PageSetup.PrintArea = "$B$1:$M$36"
   .PrintOut
End With
 Worksheets("Sheet2").Unprotect Password:="Spreedsheet"
Sheets("Sheet1").Range("E5").Copy
Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("E9").Copy
Sheets("Sheet2").Range("C" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("E15").Copy
Sheets("Sheet2").Range("D" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("E27").Copy
Sheets("Sheet2").Range("F" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("E21").Copy
Sheets("Sheet2").Range("G" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("E23").Copy
Sheets("Sheet2").Range("H" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K21").Copy
Sheets("Sheet2").Range("AH" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K17").Copy
Sheets("Sheet2").Range("K" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K9").Copy
Sheets("Sheet2").Range("L" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K35").Copy
Sheets("Sheet2").Range("M" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K15").Copy
Sheets("Sheet2").Range("N" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K25").Copy
Sheets("Sheet2").Range("O" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K31").Copy
Sheets("Sheet2").Range("P" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K20").Copy
Sheets("Sheet2").Range("j" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("E7").Copy
Sheets("Sheet2").Range("AB" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K29").Copy
Sheets("Sheet2").Range("AC" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K27").Copy
Sheets("Sheet2").Range("AD" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("K23").Copy
Sheets("Sheet2").Range("AE" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Sheet1").Range("E5,G5,I5,K5,K9,E7,E9,K11,E13,K15,K19,K21,E21,K23,E23,K25,E25,K27,E27,K29,K31,K35").ClearContents
Sheets("Sheet1").Range("K23").Select
    ActiveCell.FormulaR1C1 = "0"
Sheets("Sheet1").Range("E25").Select
    ActiveCell.FormulaR1C1 = "0"
Sheets("Sheet1").Range("E11").Select
Sheets("Sheet1").Range("E11").Formula = "=E9+364"
Sheets("Sheet1").Range("K31").Select
Sheets("Sheet1").Range("K31").Formula = "=IF(I31=""Payment Date"",Q11,0)"
Sheets("Sheet1").Range("K29").Select
Sheets("Sheet1").Range("K29").Formula = "=IF(K27=""none"",0,"""")"
Sheets("Sheet1").Range("E25").Select
Sheets("Sheet1").Range("E25").Formula = "0"
Sheets("Sheet1").Range("E17").Select
Sheets("Sheet1").Range("E17").Formula = "5%"
Worksheets("Sheet2").Protect Password:="Spreedsheet"
Sheets("Sheet1").Range("E5").Select
ThisWorkbook.Save

ActiveWorkbook.Close savechanges:=False
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

hope someone can help me!

Tony
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,668
Messages
6,120,825
Members
448,990
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top