Consulting

Results 1 to 2 of 2

Thread: Input user form to change cell value

  1. #1

    Input user form to change cell value

    Hello i need help to create User form displaying current cell value in List box and by typing text to the List box and pressing button to update cell value.
    Button for new line and current date will be also nice to have.

    All this is to be able to fill cell value and be able to use normal enter and not Alt+Enter for new line.
    1113.jpg

    Thank You!

  2. #2
    You need a text box on your userform, not a list box, then you can use the following code, which assumes default names for the form, the text box and the button,

    Option Explicit
    
    
    Private Sub CommandButton1_Click()
        Selection.Cells(1) = TextBox1.value
        Hide
    End Sub
    
    
    Private Sub UserForm_Initialize()
        With TextBox1
            .EnterKeyBehavior = True
            .MultiLine = True
            .Text = Selection.Cells(1).Text
        End With
    End Sub
    and call the form with the following macro

    Option Explicit
    
    Sub ShowForm()
        With UserForm1
            .Show
            Unload UserForm1
        End With
    lbl_Exit:
        Exit Sub
    End Sub
    Wouldn't Alt+Enter be altogether simpler?
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

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