• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to fix issue with lables

Joe Mazzone

New Member
Hello. I made a pretty simple form, and I feel it works perfectly. I wanted to add a label for each item, "Vendidos" and "in stock" and that shows me the percentages. It works wonderfully, but only on some labels; it does not show the full percentage and remains as cut:
1698478619754.png
How can I fix that little detail? Can something be done?
I would appreciate it a lot.
 

Attachments

  • ARTICULOS (1).xlsm
    45.5 KB · Views: 7
Perhaps don't bother to set the width, instead, Autosize and turn Wordwrap off (both of which you can do at design time instead of coding for them):
Code:
Private Sub ActualizarGráfico()
With Sheets("ITEMS")
  'maxcost = WorksheetFunction.Max(.Range("C2:C13"))
  For X = 1 To 12
    Controls("T" & X).Caption = .Range("A" & X + 1)
    Controls("G" & X).Caption = .Range("B" & X + 1)
    Controls("V" & X).Caption = .Range("D" & X + 1)
    Controls("S" & X).Caption = .Range("E" & X + 1)
    With Controls("VP" & X)
      '.Width = (Sheets("ITEMS").Range("F" & X + 1) / maxcost) * 12000 ' Muestra barra de porcentages de Vendidos
      .WordWrap = False
      .AutoSize = True
      .Caption = Sheets("ITEMS").Range("F" & X + 1).Text
    End With
    With Controls("IP" & X)
      '.Width = (Sheets("ITEMS").Range("G" & X + 1) / maxcost) * 12000 ' Muestra barra de porcentages de In Stock
      .WordWrap = False
      .AutoSize = True
      .Caption = Sheets("ITEMS").Range("G" & X + 1).Text
    End With
  Next
End With
End Sub
 
Last edited:
The penny's just dropped; you were trying to get the label widths to be more or less proportional to the percentages.
Try:
Code:
Private Sub ActualizarGráfico()
With Sheets("ITEMS")
  maxcost = WorksheetFunction.Max(.Range("C2:C13"))
  For X = 1 To 12
    Controls("T" & X).Caption = .Range("A" & X + 1)
    Controls("G" & X).Caption = .Range("B" & X + 1)
    Controls("V" & X).Caption = .Range("D" & X + 1)
    Controls("S" & X).Caption = .Range("E" & X + 1)
    With Controls("VP" & X)
      .Width = (Sheets("ITEMS").Range("F" & X + 1) / maxcost) * 12000 ' Muestra barra de porcentages de Vendidos
      .Width = Application.Max(18, (Sheets("ITEMS").Range("F" & X + 1) / maxcost) * 12000) ' Muestra barra de porcentages de In Stock
      .WordWrap = False
     ' .AutoSize = True
      .Caption = Sheets("ITEMS").Range("F" & X + 1).Text
    End With
    With Controls("IP" & X)
      .Width = Application.Max(18, (Sheets("ITEMS").Range("G" & X + 1) / maxcost) * 12000) ' Muestra barra de porcentages de In Stock
      .WordWrap = False
     ' .AutoSize = True
      .Caption = Sheets("ITEMS").Range("G" & X + 1).Text
    End With
  Next
End With
End Sub
 
Back
Top