av8tordude
05-07-2020, 09:35 PM
Can someone assist with a VBA code that will loop through a Userform Listbox to insert Columns 1 (Quantity), 2 (Price), 3 (Broker Fee) into the spreadsheet column T - AH of the Active Row?
The code only puts the last row into the first 3 columns (T,U,V). I'm trying to put each row (Lot #) into the corresponding column. Here's my attempt at it
Private Sub cbSubmit_Click()Dim LRow As Long, lCol2 As Long, i As Long
Dim dQty As Double, dPrice As Double, dFee As Double
LRow = ActiveCell.Row
lCol2 = 20
With lbxLots
dQty = CDbl(.List(.ListCount - 1, 1))
dPrice = CDbl(.List(.ListCount - 1, 2))
dFee = CDbl(.List(.ListCount - 1, 3))
End With
With lbxLots
For i = 0 To .ListCount - 1
Cells(LRow, lCol2).Resize(, 3) = Array(dQty, dPrice, dFee)
Next i
End With
End Sub
Graciously appreciate your help. Thx
The code only puts the last row into the first 3 columns (T,U,V). I'm trying to put each row (Lot #) into the corresponding column. Here's my attempt at it
Private Sub cbSubmit_Click()Dim LRow As Long, lCol2 As Long, i As Long
Dim dQty As Double, dPrice As Double, dFee As Double
LRow = ActiveCell.Row
lCol2 = 20
With lbxLots
dQty = CDbl(.List(.ListCount - 1, 1))
dPrice = CDbl(.List(.ListCount - 1, 2))
dFee = CDbl(.List(.ListCount - 1, 3))
End With
With lbxLots
For i = 0 To .ListCount - 1
Cells(LRow, lCol2).Resize(, 3) = Array(dQty, dPrice, dFee)
Next i
End With
End Sub
Graciously appreciate your help. Thx