Retrieving data from a worksheet to userform

  • Thread starter Thread starter Big Chris
  • Start date Start date
B

Big Chris

Hi!

I'm getting better and growing more confident by the day with VBA...bu
this just leads to me pushing my boundaries again!

I've sure this must be fairly simple, but several searches haven'
found my answer:

I want to bring up a userform which will automatically retrieve dat
from a worksheet in the workbook and display it. Maybe just a nam
like....

Today's winner is:
John Smith
Congratulations!

Can I import it straight into a text box? If yes, can I insert it int
existing text? i.e. "Congratulations to John Smith who wins today
prize".

Many thanks for sparing the time to look

Bon Weekend
 
i dont know if I undertand your question. but here I go

you can use

MsgBox "Congratulations to " & Sheets("sheet1").Range("a1").Value & "
who wins todays prize"

or if you have a form and a label then

label1.caption = "Congratulations to " &
Sheets("sheet1").Range("a1").Value & " who wins todays prize"

assuming that the name of the person is in a1

Hope it helps.

Cesar Zapata
 
If you just want to display a message, you could use a macro similar to
the following, where the name is in cell B4 --

Sub WinnerName()
MsgBox "Today's winner is:" & Chr(10) _
& Worksheets("Sheet1").Range("B4").Value _
& Chr(10) & "Congratulations!"
End Sub
 
Thanks everyone! I really appreciate your help.

I forgot to mention that I want a background images in the box an
that's why I was thing 'userform', so Cesar's reply best suits m
need....and works perfectly!

Many thanks again
 
Back
Top