VBA inputbox user new line

BlueBeerR

New Member
Joined
Jan 29, 2020
Messages
2
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
Hi,
I have a VBA code that gets input from the user.
I want that click on ENTER will get a new line.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi,
I have a VBA code that gets input from the user.
I want that click on ENTER will get a new line.

Hi,
welcome to forum
It would be helpful if you can Publish your code - plenty on forum to offer assistance.

Dave
 
Upvote 0
Hi,
Here is the code
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim str As String
Dim newTXT As String
str = Target.Value
newTXT = InputBox(str, ActiveCell.offSet(0, -1).Value, str)
Target.Value = newTXT
Range("A1").Select
End Sub
 
Upvote 0
Yeah, an InputBox won't work that way. You either have to build a UserForm with a textbox that accepts a line break, or you can use some kind of indication where the line break should go. For example, insert a line break where the user types <newline>.
 
Upvote 0
I'm not sure what you want to do.
Do you mean like this? :
VBA Code:
Target.Value = newTXT & vbCrLf
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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