Append userform textbox adding date, UserName and carriage return

srschicago

Board Regular
Joined
Apr 14, 2017
Messages
59
I am using a Userform to add to cell text. I want to have the date and UserName automatically added to the next row after the current cell text and a carriage return, setting up the user to begin typing.
I know of the Application.Username, and Me.Textbox1.Value = Format(Date, "mm/dd/yy") codes, but am not sure how to use them in what I am trying to accomplish,
I have the following code that retrieves the current cell text and loads it into the userform:
Code:
Private Sub CommandButton1_Click()
    Set myrange = Application.InputBox( _
    prompt:="Select the cell you want to edit", Title:="Edit Cell Text", Type:=8)
        myrange.Select
        
'set screen update to off
    Application.ScreenUpdating = False
    EditCellText.TextBox1.Text = CStr(myrange.Value)
    EditCellText.Show
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try this:

Code:
Private Sub CommandButton1_Click()
    Set myrange = Application.InputBox( _
    prompt:="Select the cell you want to edit", Title:="Edit Cell Text", Type:=8)
        myrange.Select
        
'set screen update to off
    Application.ScreenUpdating = False
    EditCellText.TextBox1.MultiLine = True
    EditCellText.TextBox1.Text = CStr(myrange.Value) & vbNewLine & _
        Application.UserName & vbNewLine & Format(Date, "mm/dd/yy") & vbNewLine
    EditCellText.Show
End Sub

Regards,

CJ
 
Upvote 0
That works perfectly! (as you knew it would)
Thanks MrIfOnly. Your rates are acceptable, but where to pay? :)
 
Upvote 0

Forum statistics

Threads
1,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top