Simon Campbell
New Member
- Joined
- Oct 12, 2021
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
I am so close, yet so far..
I have a simple UserForm (frm_EditFracGrad), with a list box (ltb_FracGrad) displaying 2 columns of data from a Sheet "EXTRAS", from Range "B80:C92"
I have two textboxes (txt_EditPressure & txt_EditDepth) in the User Form that display a selected row from the Listbox. in order to edit the displayed values I have a command button (cmd_SaveEditFracGrad) that transfers the new values back to the Spreadsheet. When I perform the operation I only seem to be able to edit and Save a single column from the Listbox, It will not work for both.
I'm a novice in VBA and Desparatly need some help on this... can anyone show me what I'm doing wrong
The Code is
'Initialize Form
Private Sub UserForm_Initialize()
me.ltb_FracGrad.List = ThisWorkbook.Worksheets("EXTRAS").Range("B80:C92").Value
End Sub
'Select Row in Listbox
Private Sub ltb_FracGrad_Click()
frm_EditFracGrad.txt_EditPressure.Value = Me.ltb_FracGrad.Column(0)
frm_EditFracGrad.txt_EditDepth.Value = Me.ltb_FracGrad.Column(1)
End Sub
'Save Data back to Sheet
Private Sub cmd_SaveEditFracGrad_Click()
frm_EditFracGrad.ltb_FracGrad.Column(0) = txt_EditPressure.Value
frm_EditFracGrad.ltb_FracGrad.Column(1) = txt_EditDepth.Value
Dim x
x = Me.ltb_FracGrad.List
ThisWorkbook.Worksheets("EXTRAS").Range("B80:C92").Value = x
End Sub
I have a simple UserForm (frm_EditFracGrad), with a list box (ltb_FracGrad) displaying 2 columns of data from a Sheet "EXTRAS", from Range "B80:C92"
I have two textboxes (txt_EditPressure & txt_EditDepth) in the User Form that display a selected row from the Listbox. in order to edit the displayed values I have a command button (cmd_SaveEditFracGrad) that transfers the new values back to the Spreadsheet. When I perform the operation I only seem to be able to edit and Save a single column from the Listbox, It will not work for both.
I'm a novice in VBA and Desparatly need some help on this... can anyone show me what I'm doing wrong
The Code is
'Initialize Form
Private Sub UserForm_Initialize()
me.ltb_FracGrad.List = ThisWorkbook.Worksheets("EXTRAS").Range("B80:C92").Value
End Sub
'Select Row in Listbox
Private Sub ltb_FracGrad_Click()
frm_EditFracGrad.txt_EditPressure.Value = Me.ltb_FracGrad.Column(0)
frm_EditFracGrad.txt_EditDepth.Value = Me.ltb_FracGrad.Column(1)
End Sub
'Save Data back to Sheet
Private Sub cmd_SaveEditFracGrad_Click()
frm_EditFracGrad.ltb_FracGrad.Column(0) = txt_EditPressure.Value
frm_EditFracGrad.ltb_FracGrad.Column(1) = txt_EditDepth.Value
Dim x
x = Me.ltb_FracGrad.List
ThisWorkbook.Worksheets("EXTRAS").Range("B80:C92").Value = x
End Sub