+ Reply to Thread
Results 1 to 12 of 12

Link User Form Text Box to worksheet cell

  1. #1
    Registered User
    Join Date
    02-18-2005
    Posts
    44

    Link User Form Text Box to worksheet cell

    I have a user form that allows the user to input values. Behind the scen I have a matrix that depending on what the user inputs will return certain values in a cell using the INDEX function. I would like the results to display on the User Form in a field. My question is how to I link the Text box on the user form to the calculated field on the worksheet?

  2. #2
    Forum Contributor
    Join Date
    09-28-2006
    Posts
    122
    this code will fill TextBox1 with the contents of the cell refered to (you will need to edit SheetName, RowNumber & ColNumber to meet your requirements

    TextBox1.Value = Sheets("SheetName").Cells(RowNumber, ColNumber)
    I presuume you will need to link this to an 2event" on your userform

    let me know how you go

    hth

  3. #3
    Registered User
    Join Date
    02-18-2005
    Posts
    44
    It still is not working. It will not display the results. The cell I am trying to link to is H2. My worksheet is Sheet1 This is what I have for my code right now:

    Private Sub TextBox3_Change()
    TextBox3.Value = Worksheets("Sheet1").Cells(H, 2)
    End Sub

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Use "Cells(2, 8)" to refer to cell H2. It's Cells(ROW, COLUMN), and H is the 8th column (8th letter).

  5. #5
    Registered User
    Join Date
    02-18-2005
    Posts
    44
    Still doesn't work. This is what my code looks like after the recent change:

    Private Sub TextBox3_Change()
    TextBox3.Value = Worksheets("Sheet1").Cells(2, 8)
    End Sub

  6. #6
    Registered User
    Join Date
    02-18-2005
    Posts
    44
    I got it. You can use the Control Source to link it to the cell needed.

  7. #7
    Registered User
    Join Date
    05-13-2011
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Link User Form Text Box to worksheet cell

    Quote Originally Posted by jamphan View Post
    I got it. You can use the Control Source to link it to the cell needed.
    VBA code would look like

    Please Login or Register  to view this content.
    This will pass the value from Cell H2 on Sheet1 to the specified Textbox.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Link User Form Text Box to worksheet cell

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  9. #9
    Registered User
    Join Date
    05-13-2011
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Link User Form Text Box to worksheet cell

    royUK --- Are you directing your reply to my post (which follows the rules) or to the original post (jamphan). You should probably be specific when you post a reply to a reply.

    Hope that helps

    caper1965
    -----

  10. #10
    Registered User
    Join Date
    02-23-2014
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Link User Form Text Box to worksheet cell

    Hi Caper1965.

    I saw your post and have tried the same as below

    [I][I][I]Re: Link User Form Text Box to worksheet cell
    Quote Originally Posted by jamphan View Post

    I got it. You can use the Control Source to link it to the cell needed.
    VBA code would look like



    copy to clipboard
    TextBox3.Value = WorkSheets("Sheet1").Range("$H$2").Value
    This will pass the value from Cell H2 on Sheet1 to the specified Textbox.

    I have a drop down combobox (Customer names) that refers to cell D8 and then cell D6 uses a Vlookup to retrieve the selected customers account number and display it in cell D6. How do I get the result shown in D6 to show in a textbox in a user form?

  11. #11
    Registered User
    Join Date
    07-19-2014
    Location
    Malaysia
    MS-Off Ver
    2013
    Posts
    18

    Re: Link User Form Text Box to worksheet cell

    what if i have to copy data from text box to another code?

  12. #12
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Link User Form Text Box to worksheet cell

    Hi, Aleemaher,

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1