View Full Version : Solved: Updating sheet

11-04-2007, 01:28 PM
I have seen some examples on how to retrieve data from a sheet to a list box etc, but I cannot find any help on updating sheets from a userform.

Any help would be appreciated.:help

11-04-2007, 06:22 PM
There are so many ways. Tell us more about the userform, what controls need to be extracted, and about the sheet, what does the data look like, where does the userform data go?

11-06-2007, 06:19 AM
This is the code to call up data from the sheet. This gets displayed in a textbox. What I want to do is to add a button to update any changes made in the textboxes to the sheet.

Private Sub ListBox1_Change()
Dim SourceRange As Excel.Range
Dim Val1 As String, Val2 As String, Val3 As String
If (ListBox1.RowSource <> vbNullString) Then
'Get Range that the ListBox is bound to
Set SourceRange = Range(ListBox1.RowSource)
'Get first data row
Set SourceRange = Range("Sheet1!A2:C2")
Exit Sub
End If
Val1 = ListBox1.Value
'Get the value of the second column
Val2 = SourceRange.Offset(ListBox1.ListIndex, 1).Resize(1, 1).Value
'Get the value of the third column
Val3 = SourceRange.Offset(ListBox1.ListIndex, 2).Resize(1, 1).Value
'Concatenate the three values together and display them in Label1
'Label1.Caption = "Selected Data: " & vbNewLine & Val1 & " " & Val2 & " " & Val3
' Ek het dit verander dat jy die waardes in die text bokse aantoon
TextBox1.Value = Val1
TextBox2.Value = Val2
TextBox3.Value = Val3

'Clean Up
Set SourceRange = Nothing
End Sub