Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-06-28
3
Medium Priority
?
1,016 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 1000 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

721 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