Consulting

Results 1 to 7 of 7

Thread: Vertical progress bar with label and changing height - only "grows" downward

  1. #1

    Vertical progress bar with label and changing height - only "grows" downward

    I created a horizontal progress bar by increasing the width value of a label, and the label grew to the right, which was fine.

    I then tried to create a vertical progress bar, but it grows down instead of up from the bottom.


    Sub RunStatusBar4(cellNum As Integer, totalCells As Integer)    
    With StatusBar
            .Bar4.Height = 426 * (cellNum / totalCells)
            .FrameProgressBarFull.Caption = Int((cellNum / totalCells) * 100) & "%"
            .LabelTotalValuesChanged = cellNum
        End With
    End Sub

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    I think I can do this, but could you attach a workbook with the progress bar as it is, then I can be sure any solution I offer is going to work for you?
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    thanks, here it is
    Attached Files Attached Files

  4. #4
    I didn't fix it but I found a workaround, just put a label on top and made it grow backwards. barsizeGlobal is the height of the label which is taken from the height property at the start, instead of hardcoding it like I did above.

    Sub RunStatusBar4(cellNum As Integer, totalCells As Integer)    With UserForm1
            '.Bar4.Height = barsizeGlobal * (cellNum / totalCells)
            .Bar4White.Height = barsizeGlobal - (barsizeGlobal * (cellNum / totalCells))
            .FrameProgressBarFull.Caption = Int((cellNum / totalCells) * 100) & "%"
        End With
    End Sub
    Attached the fix for anyone else who might run into it, unless you know a different way. I was thinking maybe there's a property that sets the "anchor" or the text behavior on the label, or a way to rotate it, but didn't find anything.
    Attached Files Attached Files

  5. #5
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    try on your first attached file:
    Sub RunStatusBar4(cellNum As Integer, totalCells As Integer)
    With UserForm1
      ht = 426 * (cellNum / totalCells)
      .Bar4.Top = 426 - ht
      .Bar4.Height = ht
      .FrameProgressBarFull.Caption = Int((cellNum / totalCells) * 100) & "%"
    End With
    End Sub
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  6. #6
    you can also set the Bar4 (green) to "Bring Forward" and use this code (same as #5):
    Sub RunStatusBar4(cellNum As Integer, totalCells As Integer)    Dim h As Integer
        With UserForm1
            '.Bar4.Height = barsizeGlobal * (cellNum / totalCells)
            '.Bar4White.Height = barsizeGlobal - (barsizeGlobal * (cellNum / totalCells))
            With .Bar4
                h = barsizeGlobal * (cellNum / totalCells)
                .Top = barsizeGlobal - h
                .Height = h
            End With
            .FrameProgressBarFull.Caption = Int((cellNum / totalCells) * 100) & "%"
        End With
    End Sub
    
    
    Private Sub UserForm_Initialize()
    With Me.Bar4
        .Height = 0
        .Top = barsizeGlobal
    End With
    End Sub
    
    
    
    
    Private Sub CommandButton1_Click()
        ThisWorkbook.runit
    End Sub
    Attached Files Attached Files

  7. #7
    Thanks so much to both of you, this is more what I was looking for!

Posting Permissions

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