Problem with my Label's on userform

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
207
Hey Excel Ekspert's

on my userform1 i have 8 Label's there Are taking Data from 8 Different's Cell's
my Problem is that the Label NOT is Opdating Automatik only when i Click On the Specific Label

i Might see the Problem in the Startline of my Code "Private Sub Label71_Click()" But i don't know how to Change that Code

Label71 - Label78

Code:
Private Sub Label71_Click()Me.Label71.Caption = ThisWorkbook.Sheets("Cup 128").Range("E267")
resetLabels
End Sub


Private Sub Label72_Click()
Me.Label72.Caption = ThisWorkbook.Sheets("Cup 128").Range("E273")
resetLabels
End Sub


Private Sub Label73_Click()
Me.Label73.Caption = ThisWorkbook.Sheets("Cup 128").Range("E279")
resetLabels
End Sub


Private Sub Label74_Click()
Me.Label74.Caption = ThisWorkbook.Sheets("Cup 128").Range("E285")
resetLabels
End Sub


Private Sub Label75_Click()
Me.Label75.Caption = ThisWorkbook.Sheets("Cup 128").Range("E291")
resetLabels
End Sub


Private Sub Label76_Click()
Me.Label76.Caption = ThisWorkbook.Sheets("Cup 128").Range("E297")
resetLabels
End Sub


Private Sub Label77_Click()
Me.Label77.Caption = ThisWorkbook.Sheets("Cup 128").Range("E303")
resetLabels
End Sub


Private Sub Label78_Click()
Me.Label78.Caption = ThisWorkbook.Sheets("Cup 128").Range("E309")
resetLabels
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
When do you want to update the Labels.
For example, when activating the userform:

Code:
Private Sub UserForm_Activate()
  Call start_Labels
End Sub


Sub start_Labels()
  Me.Label71.Caption = ThisWorkbook.Sheets("Cup 128").Range("E267")
  Me.Label72.Caption = ThisWorkbook.Sheets("Cup 128").Range("E273")
  Me.Label73.Caption = ThisWorkbook.Sheets("Cup 128").Range("E279")
  Me.Label74.Caption = ThisWorkbook.Sheets("Cup 128").Range("E285")
  Me.Label75.Caption = ThisWorkbook.Sheets("Cup 128").Range("E291")
  Me.Label76.Caption = ThisWorkbook.Sheets("Cup 128").Range("E297")
  Me.Label77.Caption = ThisWorkbook.Sheets("Cup 128").Range("E303")
  Me.Label78.Caption = ThisWorkbook.Sheets("Cup 128").Range("E309")
End Sub

If you are making a calculation and want to see the result of the calculation reflected in the Labels, then after the calculation execute the procedure "start_Labels"


Note: You can simplify start_Labels like this:
Code:
Sub start_Labels()
  Dim i As Long, n As Long
  n = 267
  For i = 71 To 78
    Me.Controls("Label" & i).Caption = ThisWorkbook.Sheets("Cup 128").Range("E" & n)
    n = n + 6
  Next
End Sub
 
Upvote 0
Thank you Dante Amor

it works with this Code

Code:
[COLOR=#333333]Private Sub UserForm_Activate()[/COLOR]  Call start_Labels
End Sub


Sub start_Labels()
  Me.Label71.Caption = ThisWorkbook.Sheets("Cup 128").Range("E267")
  Me.Label72.Caption = ThisWorkbook.Sheets("Cup 128").Range("E273")
  Me.Label73.Caption = ThisWorkbook.Sheets("Cup 128").Range("E279")
  Me.Label74.Caption = ThisWorkbook.Sheets("Cup 128").Range("E285")
  Me.Label75.Caption = ThisWorkbook.Sheets("Cup 128").Range("E291")
  Me.Label76.Caption = ThisWorkbook.Sheets("Cup 128").Range("E297")
  Me.Label77.Caption = ThisWorkbook.Sheets("Cup 128").Range("E303")
  Me.Label78.Caption = ThisWorkbook.Sheets("Cup 128").Range("E309") [COLOR=#333333]End Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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