Tarkemelion
New Member
- Joined
- Jun 28, 2022
- Messages
- 21
- Office Version
- 365
- Platform
- Windows
Hi All,
I have a button that leads to a UserForm where the User enters in some information and is prompted with an InputBox. The intention is that the user types in the row that they want the aforementioned UserForm information to be placed. I seem to be struggling with transferring the row entered into the InputBox as a value which can then be used. Feedback and advice is appreciated!
I have a button that leads to a UserForm where the User enters in some information and is prompted with an InputBox. The intention is that the user types in the row that they want the aforementioned UserForm information to be placed. I seem to be struggling with transferring the row entered into the InputBox as a value which can then be used. Feedback and advice is appreciated!
VBA Code:
Private Sub cmdAdd_Click()
'Define the variables
Dim Invoice_Number As String
Dim Invoice_Value As String
Dim Ret1 As Long
Dim lRow As Range
Dim ws As Worksheet
'Sets variables to UserForm values
Invoice_Number = TextBox1.Text
Invoice_Value = TextBox2.Text
Set ws = ThisWorkbook.Worksheets("Cost Detail")
Set tbl = ws.ListObjects("Table1")
'Specify row to add information
On Error Resume Next
Ret1 = Application.InputBox("Which Docket is associated with the Invoice", "Add Invoice")
On Error GoTo 0
'Add information if row is associated with a docket
If lRow > 18 Then
With lRow
.Range(14) = Invoice_Number
.Range(15) = Invoice_Value
End With
ElseIf Ret1 <= 18 Then
MsgBox "This is not a docket row!!!"
End If
'Closes UserForm
Unload Me
End Sub