Link to home
Start Free TrialLog in
Avatar of Geekamo
GeekamoFlag for United States of America

asked on

Add Formula To Label Control on UserForm

Hello Experts,

I have a UserForm, that will eventually become a "popup" window that is splashed on the screen when the user opens the Excel Workbook.

I have added a "Label" control onto my UserForm, and I would like it to display the result of this formula:

="Version - "&LOOKUP(90000000000,'Change Log'!A:A)&" (Jay Burke)"

I tried adding the formula right into the Label control, and it just shows the formula itself - not the result.  So either, I need to do something else? Or it's just not something that is supported?

Thank you in advance for your help!

~ Geekamo
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Try

evaluate(="Version - "&LOOKUP(90000000000,'Change Log'!A:A)&" (Jay Burke)")
Avatar of Geekamo

ASKER

Nope, doesn't work.  It still just shows the formula.
You could set the caption to the value of the cell that has the formula.
Private Sub UserForm_Activate()
    Label1.Caption = Sheets(5).Range("C3").Value
End Sub

Open in new window

Avatar of Geekamo

ASKER

@ Graham,

Could you revise that formula to reference a named cell instead?
Avatar of Rgonzo1971
Rgonzo1971

and to paraphrase Syed

Label1 = "Version - " & Evaluate("=LOOKUP(90000000000,'Macro'!A:A)") & " (Jay Burke)"

Regards
Just plug the name into the code
Private Sub UserForm_Activate()
    Label1.Caption = Sheets(5).Range("MyCell").Value
End Sub

Open in new window

Avatar of Geekamo

ASKER

I'm not having any luck...

Can someone post a workbook that has a userform, and a label control is looking at a specific cell for it's value?

Hopefully that will help me out.
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Geekamo

ASKER

@ GrahamSkan,

So weird, I couldn't figure out what I was doing wrong.  Your version looked the same as mine - except I was referencing other names.

Anyhow, I copied and pasted yours - changed the names to this:

Private Sub UserForm_Activate()
    'Label1.Caption = Sheets(5).Range("C3")
    lblVersion.Caption = Range("Version")
End Sub

Open in new window


On your example that was referencing the named cell, I was wondering why it still needed to reference the sheet name.  So on a hunch, I just removed it - and it's working perfectly.

Thank you very much for taking the time to help me with this!

~ Geekamo