Hello Everyone,
I’m hoping someone can help me as I’m having a hard time figuring this out. What I’d like to do:
As I type a number in the textbox, I’d like the amount to appear alongside in the listbox .
When I click on the transfer button, I’d like the listbox values to populate my table on sheet 1. Below is the code, I’m also including the workbook for clarity. Thank you in advance.
Private Sub TransferData_Click()
Dim i As Long
Dim ws As Worksheet
Dim nextAvailableRow As Long
'check if listbox is empty
If Listbox1.ListCount = 0 Then
MsgBox "Nothing Has Been Added", vbInformation, "ListBox Empty"
Exit Sub
End If
Set ws = Sheets("Sheet2")
For i = 0 To Listbox1.ListCount - 1
nextAvailableRow = ws.Range("B" & Rows.Count).End(xlUp).Row + 1
ws.Range("b" & nextAvailableRow) = Listbox1.Column(0, i)
ws.Range("c" & nextAvailableRow) = Listbox1.Column(1, i)
ws.Range("d" & nextAvailableRow) = Listbox1.Column(2, i)
Next i
Listbox1.Clear
End Sub
Private Sub UserForm_Activate()
For i = 1 To 5
Me.Controls("Label" & i).Caption = Me.Controls("Label" & i).Name
Next i
End Sub
Sub getSum()
On Error Resume Next
For i = 1 To 5
If Me.Controls("Textbox" & i) <> Empty Then
cntr = cntr
End If
cVal = cVal + CDbl(Me.Controls("Textbox" & i))
Next i
Me.TextBox11 = cVal + cntr
End Sub
Private Sub TextBox1_Change()
getSum
Me.Listbox1.AddItem
Me.Listbox1.List(pos, 0) = Me.TextBox1
End Sub
Private Sub TextBox2_Change()
getSum
Me.Listbox1.AddItem
Me.Listbox1.List(pos, 1) = Me.TextBox2
End Sub
Private Sub TextBox3_Change()
getSum
End Sub
Private Sub TextBox4_Change()
getSum
End Sub
Private Sub TextBox5_Change()
getSum
End Sub
Private Sub TextBox6_Change()
getSum
End Sub
Private Sub TextBox7_Change()
getSum
End Sub
Private Sub TextBox8_Change()
getSum
End Sub
Private Sub TextBox9_Change()
getSum
End Sub
Private Sub TextBox10_Change()
getSum
End Sub