Hello all!
Basically, the sheet I have records reorders for product. Currently, it only accepts one item at a time. We can copy multiple lines from our ordering software, and they can paste into Word or another Excel sheet fine. However, my user form will only accept the first line when pasted into it. Is there something I can add to my code to get it to accept multiple lines/breaks into the box?
The user form ID is frmInput
Thanks for the help!
Sub getActionInput()
Dim userAnswers() As String
Dim i As Integer
Dim last As Integer
Dim adminMessage As String
Dim adminFlag As Boolean
Dim start As Integer
formattedAnswers = "" 'erase old input
start = 0
ReDim userAnswers(UBound(actionString))
For i = 0 To UBound(actionString)
If i = 0 And InStr(actionString(i), "#!") > 0 Then
If MsgBox(Replace(actionString(i), "#!", "") & vbLf & vbLf & "Do you want to continue?", vbQuestion + vbYesNo + vbDefaultButton1, "Continue?") = vbNo Then
exitFlag = True
Exit Sub
Else
start = 1
i = i + 1
End If
End If
With Worksheets("Formatted Answers")
frmInput.Caption = .Range("B3").Value & "-" & .Range("B4").Value
End With
frmInput.Height = 125
If i < UBound(actionString) Then
If InStr(actionString(i + 1), "#!") > 0 Then
adminMessage = Replace(actionString(i + 1), "#!", "")
frmInput.Height = 174
frmInput.admininstrativeMessage = adminMessage
adminFlag = True
Else
frmInput.Height = 125
adminFlag = False
End If
End If
frmInput.frmLabel = Replace(actionString(i), "^", "")
frmInput.textbox = actionString(i)
frmInput.Show
If exitFlag = True Then 'if user closes box
Exit Sub
End If
userAnswers(i) = tempAnswer
If userAnswers(i) <> "" Then
If i = start Then
formattedAnswers = userAnswers(i) 'no line feed on first one...
Else
formattedAnswers = formattedAnswers & vbLf & userAnswers(i)
End If
End If
If adminFlag Then
i = i + 1
End If
Next i
'Add date,username and timestamp to last line:
formattedAnswers = Format(Date, "MM/DD/YY") & " " & _
" " & Sheets("Formatted Answers").Range("B2").Value & " " & Format(Now(), "h:m:s AM/PM") & vbLf & formattedAnswers
End Sub
Bookmarks