Hello everyone,
I have a userform that have a lot of labels to show the currency values.
For that I used the code below:
Private Sub UserForm_Initialize()
Dim xp, As Double
xp = Val(xp)
xp = CDbl(xp)
lbl1.Caption = xp
lbl2.Caption = xp
lbl3.Caption = xp
xp = Sheets("sheet1").Range("A21")
xp = Sheets("sheet1").Range("B21")
xp = Sheets("sheet1").Range("C21")
lbl1.Caption = Format(xp, "#,##0.00 €")
lbl2.Caption = Format(xp, "#,##0.00 €")
lbl3.Caption = Format(xp, "#,##0.00 €")
I wound like to have a macro to simplify the code. I use macro below but didn't worked. Is it possible to agregate all, with the same formats on the labels' values?
Sub FormatValue()
With UserForm3
ary = Array(.lbl1, .lbl2, .lbl3)
For i = 0 To UBound(ary)
ary(i).Caption = Format(i, "#,##0.00 €")
Next i
End With
End Sub
I would be very grateful for the help you can give to solve this problem. Many thanks
I have a userform that have a lot of labels to show the currency values.
For that I used the code below:
Private Sub UserForm_Initialize()
Dim xp, As Double
xp = Val(xp)
xp = CDbl(xp)
lbl1.Caption = xp
lbl2.Caption = xp
lbl3.Caption = xp
xp = Sheets("sheet1").Range("A21")
xp = Sheets("sheet1").Range("B21")
xp = Sheets("sheet1").Range("C21")
lbl1.Caption = Format(xp, "#,##0.00 €")
lbl2.Caption = Format(xp, "#,##0.00 €")
lbl3.Caption = Format(xp, "#,##0.00 €")
I wound like to have a macro to simplify the code. I use macro below but didn't worked. Is it possible to agregate all, with the same formats on the labels' values?
Sub FormatValue()
With UserForm3
ary = Array(.lbl1, .lbl2, .lbl3)
For i = 0 To UBound(ary)
ary(i).Caption = Format(i, "#,##0.00 €")
Next i
End With
End Sub
I would be very grateful for the help you can give to solve this problem. Many thanks