Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How to autopopulate a textbox linked to a cell
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    916
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default How to autopopulate a textbox linked to a cell

    Hi hope you can help, I have a userform1 with multiple texboxes in and I want this to automatically load up with informaton from the 'Data' sheet into the textbox, I have done the code below but its not working, nothing appears in textbox1. for Example TextBox1 I want to look in a sheet called 'Data' and the range is B1, this is in date format dd/mm/yyyy and it should be vertical going down.. can you help please.
    Code:
    Private Sub TextBox1_Change()
    TextBox1.Value = Sheets("Data").Range("B1").Value
    End Sub

  2. #2
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    916
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to autopopulate a textbox linked to a cell

    I hope this makes sense? and I hope you can help

  3. #3
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    916
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to autopopulate a textbox linked to a cell

    I have also tried the code below but still didn't work
    Code:
    Private Sub TextBox1_Change()
    Me.TextBox1.Text = Worksheets("Data").Range("B1").Value
    End Sub

  4. #4
    Board Regular jmacleary's Avatar
    Join Date
    Oct 2015
    Location
    at a desk in the UK
    Posts
    633
    Post Thanks / Like
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to autopopulate a textbox linked to a cell

    Hi there. You need to put the code that inserts the value in the userform initialize subrutine like so:

    Code:
    Private Sub UserForm_Initialize()
    Me.TextBox1.Text = Worksheets("Data").Range("B1").Value
    End Sub
    If my answer has helped, please vote using the Thanks or Like buttons on the left.
    John

  5. #5
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    916
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to autopopulate a textbox linked to a cell

    Hi that works great thank you but how do I get it to show vertically?

  6. #6
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    916
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to autopopulate a textbox linked to a cell

    I mean vertically down, I have reshaped the text box so its going down instead of across so I need the text to go vertically down if possible?
    The height of each textbox is 82.8 and the width is 18
    Last edited by Patriot2879; Sep 16th, 2019 at 09:46 AM.

  7. #7
    Board Regular jmacleary's Avatar
    Join Date
    Oct 2015
    Location
    at a desk in the UK
    Posts
    633
    Post Thanks / Like
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to autopopulate a textbox linked to a cell

    Glad to hear it worked. I assume B1 has in it something like "16/09/2019" but I'm still unclear on exactly what you want to see. Do you mean that you want to see (in textbox1) something like this:

    1
    6
    /
    0
    9
    /
    2
    0
    1
    9
    If my answer has helped, please vote using the Thanks or Like buttons on the left.
    John

  8. #8
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    916
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to autopopulate a textbox linked to a cell

    that's it yes please how do I do that please

  9. #9
    Board Regular
    Join Date
    Feb 2018
    Location
    Midlands, UK
    Posts
    916
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to autopopulate a textbox linked to a cell

    but if I can have it going thsi way please
    9
    1
    0
    2
    \
    8
    0
    \
    2
    2

    For example

  10. #10
    Board Regular jmacleary's Avatar
    Join Date
    Oct 2015
    Location
    at a desk in the UK
    Posts
    633
    Post Thanks / Like
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Default Re: How to autopopulate a textbox linked to a cell

    Try this:
    Code:
    Private Sub UserForm_Initialize()
    Dim DateStr As String
    Dim ResultStr As String
    DateStr = Worksheets("Data").Range("B1").Text
    ResultStr = Right(DateStr, 1)
    For i = Len(DateStr) - 1 To 1 Step -1
        ResultStr = ResultStr & vbCrLf & Mid(DateStr, i, 1)
    Next i
    Me.TextBox1.MultiLine = vbTrue
    Me.TextBox1.Text = ResultStr
    End Sub
    If my answer has helped, please vote using the Thanks or Like buttons on the left.
    John

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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