Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
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…

820 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