View Full Version : Input user form to change cell value
xaxaredbul
12-12-2019, 01:52 AM
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.
25621
Thank You!
gmayor
12-12-2019, 02:49 AM
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?
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.