Userform entries to be inserted in section of row range

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

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
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try
Code:
lRow = Choose(Me.ComboBox1.Value, 2, 32, 42)
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top