Hi There,
Attached is a spreadsheet with a very basic userform. The userform is loaded when a cell in column A is selected. Currently, the data from the userform is sent to the first blank row; however I was wondering whether it was possible to send the data to the selected row. So for example if I selected "A9", the data from the userform would be sent to "B9, C9, D9" etc....
Here is the code I'm using:
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim Rng As Range
Dim ws As Worksheet
Set ws = Worksheets("DataSource")
Set Rng = ws.Range("A2")
iRow = ws.Cells(Rows.Count, Rng.Column).End(xlUp).Row
iRow = IIf(iRow < Rng.Row, Rng.Row, iRow + 1)
ws.Cells(iRow, 1) = example1.Value
ws.Cells(iRow, 2) = example2.Value
ws.Cells(iRow, 3) = date1.Value
ws.Cells(iRow, 4) = comboexample.Value
ws.Cells(iRow, 5) = date1.Value
ws.Cells(iRow, 6) = comboexample2.Value
ws.Cells(iRow, 7) = example5.Value
ws.Cells(iRow, 13) = comboexample3.Value
ws.Cells(iRow, 16) = comboexample4.Value
ws.Cells(iRow, 16) = comboexample5.Value
Unload Me
End Sub
Thanks for the help.
Bookmarks