Solved

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

Posted on 2013-06-28
3
788 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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 two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

776 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