Solved

Userform Textbox Default Value, pointing to a specific Workbook>Tab> and cell?

Posted on 2013-06-28
3
899 Views
Last Modified: 2013-07-02
This might be an easy one.

I am using a userform that I want to grab a specific cell text value from.  How would I tell Excel to grab the text value of WorkBook1, Sheet2 and cell b4?  Needs to be formatted as text.

Please advise and thanks. -R-
0
Comment
Question by:RWayneH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
arildj78 earned 250 total points
ID: 39285922
In Visual Basic Editor, create label1 on your userform and doubleclick the userform. The editor should appear so you can insert the following method.

Private Sub UserForm_Activate()
    Label1.Caption = Sheet2.Range("B4").Value
End Sub

Open in new window


When the form is activated this method will fire and the value in B4 is used as text in the label. If you are using a textbox you should replace Label1.Caption with TextBox1.Text.

If you would like to trigger the transfer of text on something else then the activation of the userform, you can select different events from the dropdown list in the upper right corner when editing code.
0
 
LVL 81

Assisted Solution

by:byundt
byundt earned 250 total points
ID: 39286149
To capture a cell value from another open workbook and format it as a Social Security number, you might do it like this:
Private Sub UserForm_Initialize()
TextBox1.Value = Format(Workbooks("YTD-TotalsQ28170943.xlsm").Worksheets("6-Apr-2013").Range("C15").Value, "000-00-0000")
End Sub

Open in new window

)
0
 

Author Closing Comment

by:RWayneH
ID: 39294888
Both responses worked.  Thanks  and EXCELent!!  -R-
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question