sanilmathews
Board Regular
- Joined
- Jun 28, 2011
- Messages
- 102
I have the below code which gets input from the user and inserts to a sheet called Dashboard. The bolded line of code perfectly starts from the first empty row and then work its way down for each entry.
Is there any possibility of doing the below?
Combobox1 will have 3 selection for the user. Based on the selection made in Combobox1 the data needs to be inserted into 3 specific range of rows.
For selection1, the entry would start from Row 2 and work its way down until Row 30
For selection2, the entry would start from Row 32 and work its way down until Row 40
For selection3, the entry would start from Row 42 and work its way down until Row 50 or beyond
Is there any possibility of doing the below?
Combobox1 will have 3 selection for the user. Based on the selection made in Combobox1 the data needs to be inserted into 3 specific range of rows.
For selection1, the entry would start from Row 2 and work its way down until Row 30
For selection2, the entry would start from Row 32 and work its way down until Row 40
For selection3, the entry would start from Row 42 and work its way down until Row 50 or beyond
Code:
Private Sub Add()
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Dashboard")
[B]lRow = ws.Cells(Row.Count, 1).End(xlUp).Offset(1, 0).Row
[/B]
With ws
.Cells(lRow, 1).Value = Me.txtdate.Value
.Cells(lRow, 2).Value = Me.Combobox1.Value
.Cells(lRow, 3).Value = Me.Combobox2.Value
.Cells(lRow, 4).Value = Me.Combobox3.Value
.Cells(lRow, 5).Value = Me.Combobox4.Value
End With
Me.txtdate.Value
Me.Combobox1.Value = ""
Me.Combobox2.Value = ""
Me.Combobox3.Value = ""
Me.Combobox4.Value = ""
Unload Me
End Sub