Hi,
pretty new to VBS so heeeellllppppp!!! me, please..
I have created a listbox on a page that displays the contents of another workbook. The contents of which are added via another userform titled “AddNew” I have created a duplicate userform call “Amend”.
What I’d like to be able to is to load the data that corresponds to that entry in the listbox into the “Amend” userform, where the data can be edited and saved over the original value. This would be entered by selecting either by double clicking on the selected row in the listbox or by highlighting a row and selecting another command button.
I’ve trawled the web for help but can’t find anything that closely resembles what I want to do, which is surprising.
so far i have the code below which should populate userform2 with the selected details from the listbox in userform1, however only the 1st value in a row is being populated into textbox1 and i keep getting an error message "could not set the value property"
Private Sub commandbutton1_Click()
Set SourceRange = Range(ListBox1.RowSource)
With UserForm2
.TextBox1.Value = ListBox1.Value
.TextBox2.Value = SourceRange.Offset(ListBox1.ListIndex, 1).Value
.TextBox3.Value = SourceRange.Offset(ListBox1.ListIndex, 2).Value
.TextBox4.Value = SourceRange.Offset(ListBox1.ListIndex, 3).Value
.Show
End With
End Sub
I’m still at a loss as to how to then amend the selected row so that the row in the workbook is updated with he new data.
Any help whatsoever would be greatly appreciated.
Thanks in advance
G
pretty new to VBS so heeeellllppppp!!! me, please..
I have created a listbox on a page that displays the contents of another workbook. The contents of which are added via another userform titled “AddNew” I have created a duplicate userform call “Amend”.
What I’d like to be able to is to load the data that corresponds to that entry in the listbox into the “Amend” userform, where the data can be edited and saved over the original value. This would be entered by selecting either by double clicking on the selected row in the listbox or by highlighting a row and selecting another command button.
I’ve trawled the web for help but can’t find anything that closely resembles what I want to do, which is surprising.
so far i have the code below which should populate userform2 with the selected details from the listbox in userform1, however only the 1st value in a row is being populated into textbox1 and i keep getting an error message "could not set the value property"
Private Sub commandbutton1_Click()
Set SourceRange = Range(ListBox1.RowSource)
With UserForm2
.TextBox1.Value = ListBox1.Value
.TextBox2.Value = SourceRange.Offset(ListBox1.ListIndex, 1).Value
.TextBox3.Value = SourceRange.Offset(ListBox1.ListIndex, 2).Value
.TextBox4.Value = SourceRange.Offset(ListBox1.ListIndex, 3).Value
.Show
End With
End Sub
I’m still at a loss as to how to then amend the selected row so that the row in the workbook is updated with he new data.
Any help whatsoever would be greatly appreciated.
Thanks in advance
G