MarkusLAndersson
Mechanical
Hi
I would like some help wit a UserForm that I am about to create. The UserForm is suppose to present a list for the user in a ListBox and the user is then to select one row. Depending on the selection, data will be transferred from Sheet3 to Sheet1 in my excel document. In my user form I have to buttons, one OK button and one Cancel. The OK will make the transfer and the Cancel will cancel the UserForm. Below you can se my coda so far. I can read in data to my ListBox from Sheet3 but how am I suppose to get the selected data to sheet one. As you might notice I am totally new to using VBA in excel.
-----------------------------------------------------------
Private Sub CommandButton1_Click()
End Sub
-----------------------------------------------------------
Private Sub CommandButton2_Click()
End Sub
-----------------------------------------------------------
Private Sub UserForm_Initialize()
Dim Lrange As Range
Dim Larray() As Variant
Dim x As Variant
Dim ctr As Integer
'Set the range to loop through
Set Lrange = Sheet3.Range("A2:A53")
'Loops through the ranges
For Each x In Lrange
ReDim Preserve Larray(ctr)
'Add an item to the array
Larray(ctr) = x.Value
ctr = ctr + 1
Next x
'Assign the array to the listbox
ListBox1.List = Larray
End Sub
-----------------------------------------------------------
I would like some help wit a UserForm that I am about to create. The UserForm is suppose to present a list for the user in a ListBox and the user is then to select one row. Depending on the selection, data will be transferred from Sheet3 to Sheet1 in my excel document. In my user form I have to buttons, one OK button and one Cancel. The OK will make the transfer and the Cancel will cancel the UserForm. Below you can se my coda so far. I can read in data to my ListBox from Sheet3 but how am I suppose to get the selected data to sheet one. As you might notice I am totally new to using VBA in excel.
-----------------------------------------------------------
Private Sub CommandButton1_Click()
End Sub
-----------------------------------------------------------
Private Sub CommandButton2_Click()
End Sub
-----------------------------------------------------------
Private Sub UserForm_Initialize()
Dim Lrange As Range
Dim Larray() As Variant
Dim x As Variant
Dim ctr As Integer
'Set the range to loop through
Set Lrange = Sheet3.Range("A2:A53")
'Loops through the ranges
For Each x In Lrange
ReDim Preserve Larray(ctr)
'Add an item to the array
Larray(ctr) = x.Value
ctr = ctr + 1
Next x
'Assign the array to the listbox
ListBox1.List = Larray
End Sub
-----------------------------------------------------------