+ Reply to Thread
Results 1 to 6 of 6

Progress Indicator help

Hybrid View

  1. #1
    Registered User
    Join Date
    07-27-2015
    Location
    England
    MS-Off Ver
    Office 2010
    Posts
    40

    Progress Indicator help

    Hello

    I currently use the macro below & have (unsuccessfully) tried to add a progress indicator to it. The progress indicator I've been trying to squeeze in is this really good one from John Walkenbach.

    At this stage i'm quite perplexed on how to do this. Please could someone help (& preferably add commentary so that i can learn)?

    Thanks

    Sub AppleDepartmentCode()
    
    Dim Target As Range
    Dim sContent
    Dim c As Range
    
    Set Target = Selection.SpecialCells(xlCellTypeVisible)
    
        Application.EnableEvents = False
    
    
            For Each c In Target    'for every cell in the selection
    
                If Not (c = "") Then    'if the cell in the selection is empty then move onto the next cell
    
                    sContent = c.Value      ' store the current contents of the cell
    
                    With c
                        ' put array formula in cell using the stored cell's contents
                        On Error Resume Next    ' trap any error
                        .FormulaArray = _
                            "=INDEX([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$2:$K$2,SMALL(IF([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$1:$K$40=""" & sContent & """,COLUMN([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$1:$K$40)),1))"
                        On Error GoTo 0
                        ' convert the formula to a value
                        .Value = .Value
                        ' if the value is an error type, restore the original contents
                        If Left(CStr(.Value), 5) = "Error" Then .Value = sContent
                    End With
    
                End If
    
            Next c
    
    
    Application.EnableEvents = True
    
    End Sub

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,203

    Re: Progress Indicator help

    Quote Originally Posted by SUMIF View Post
    The progress indicator I've been trying to squeeze in is this really good one from John Walkenbach.
    Your post doesn't tell us anything about the progress indicator you want to use other than that it's John's (who is great, by the way). Your code doesn't indicate any evidence of trying to use it.

    Can you please give us all the details about the progress indicator you want to use?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    07-27-2015
    Location
    England
    MS-Off Ver
    Office 2010
    Posts
    40

    Re: Progress Indicator help

    Hi 6StringJazzer

    Apologies, i had meant to link to the John Walkenbach progress indicator. It can be found here: http://spreadsheetpage.com/index.php...ess_indicator/

    PHP Code: 
    Sub Main()
    '   Inserts random numbers on the active worksheet'
        
    Dim Counter As Integer
        Dim RowMax 
    As IntegerColMax As Integer
        Dim r 
    As IntegerAs Integer
        Dim PctDone 
    As Single
        
        
    If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
        Cells
    .Clear
        Application
    .ScreenUpdating False
        Counter 
    1
        RowMax 
    100
        ColMax 
    25
        
    For 1 To RowMax
            
    For 1 To ColMax
                Cells
    (rc) = 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 
    The progress indicator bar i use doesn't have to be his but i found his explanations useful when following his code after downloading his workbook.

    I think where i'm having difficulty is that his code inputs random numbers into the worksheet to demonstrate the code. Taking this out & substituting the code in my post is quite mind boggling to me. I still look at code in small chunks but looking at it holistically is hard!

    Any pointers, suggestions or tips?

    From my code i know i somehow want to count the total number in the selection:
    PHP Code: 
    For Each c In Target    'for every cell in the selection 
    I also want to divide the following with the total number in the selection:
    PHP Code: 
    Next c 
    I would then have the percentage out of 100% but how to put it into practice?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,203

    Re: Progress Indicator help

    If you want to use his, then you can modify your code as shown:


    Sub AppleDepartmentCode()
    
    Dim Target As Range
    Dim sContent
    Dim c As Range
    Dim PctDone As Double
    Dim CellCount As Long
    
    Set Target = Selection.SpecialCells(xlCellTypeVisible)
    
        Application.EnableEvents = False
    
            CellCount = 0
            For Each c In Target    'for every cell in the selection
    
                CellCount = CellCount + 1
    
                If Not (c = "") Then    'if the cell in the selection is empty then move onto the next cell
    
                    sContent = c.Value      ' store the current contents of the cell
    
                    With c
                        ' put array formula in cell using the stored cell's contents
                        On Error Resume Next    ' trap any error
                        .FormulaArray = _
                            "=INDEX([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$2:$K$2,SMALL(IF([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$1:$K$40=""" & sContent & """,COLUMN([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$1:$K$40)),1))"
                        On Error GoTo 0
                        ' convert the formula to a value
                        .Value = .Value
                        ' if the value is an error type, restore the original contents
                        If Left(CStr(.Value), 5) = "Error" Then .Value = sContent
                    End With
    
                End If
    
               PctDone = CellCount / Target.Count
               With UserForm1 
                   .FrameProgress.Caption = Format(PctDone, "0%") 
                   .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10) 
               End With 
               DoEvents
    
            Next c
    
    
    Application.EnableEvents = True
    
    End Sub

  5. #5
    Registered User
    Join Date
    07-27-2015
    Location
    England
    MS-Off Ver
    Office 2010
    Posts
    40

    Re: Progress Indicator help

    Quote Originally Posted by 6StringJazzer View Post
    If you want to use his, then you can modify your code as shown:


    Sub AppleDepartmentCode()
    
    Dim Target As Range
    Dim sContent
    Dim c As Range
    Dim PctDone As Double
    Dim CellCount As Long
    
    Set Target = Selection.SpecialCells(xlCellTypeVisible)
    
        Application.EnableEvents = False
    
            CellCount = 0
            For Each c In Target    'for every cell in the selection
    
                CellCount = CellCount + 1
    
                If Not (c = "") Then    'if the cell in the selection is empty then move onto the next cell
    
                    sContent = c.Value      ' store the current contents of the cell
    
                    With c
                        ' put array formula in cell using the stored cell's contents
                        On Error Resume Next    ' trap any error
                        .FormulaArray = _
                            "=INDEX([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$2:$K$2,SMALL(IF([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$1:$K$40=""" & sContent & """,COLUMN([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$1:$K$40)),1))"
                        On Error GoTo 0
                        ' convert the formula to a value
                        .Value = .Value
                        ' if the value is an error type, restore the original contents
                        If Left(CStr(.Value), 5) = "Error" Then .Value = sContent
                    End With
    
                End If
    
               PctDone = CellCount / Target.Count
               With UserForm1 
                   .FrameProgress.Caption = Format(PctDone, "0%") 
                   .LabelProgress.Width = PctDone * (.FrameProgress.Width - 10) 
               End With 
               DoEvents
    
            Next c
    
    
    Application.EnableEvents = True
    
    End Sub
    Wow PM6StringJazzer, that's awesome! I've finally had a chance to implement it & it works great. Thanks alot for your help

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,203

    Re: Progress Indicator help

    You're welcome, glad to help! Thanks for the rep and thanks for marking your thread SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Progress Indicator
    By julhs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2016, 01:17 PM
  2. Progress Indicator Bar
    By abousetta in forum The Water Cooler
    Replies: 17
    Last Post: 10-01-2012, 03:34 AM
  3. Progress Bar Indicator
    By coneill0422 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2011, 07:18 PM
  4. Progress Indicator
    By excel_lover in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-20-2009, 04:59 AM
  5. progress indicator problem
    By 77anders in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2009, 07:35 AM
  6. Help with Progress indicator script
    By Les Stout in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2005, 08:05 AM
  7. [SOLVED] msgbox as a progress indicator...
    By John Keith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2005, 02:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1