Issue specifying worksheet

raccoon588

Board Regular
Joined
Aug 5, 2016
Messages
118
i have a user form that gathers some data. The following code continues to dumb the info onto the active sheet rather then sheet 13 (request log). i need it to populate the data on that sheet every time rather then on the active worksheet.

Code:
Dim erow As Long
erow = Worksheets("sheet13").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 1).Value = ComboBoxName.Value
Cells(erow, 2).Value = Date
Cells(erow, 3).Value = Time
Cells(erow, 4).Value = DTPicker1.Value
Cells(erow, 5).Value = DTPicker2.Value
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hello Raccoon588,


Try qualifying the destination sheet a little more such as:-


Code:
Dim erow As Long
Dim ws As Worksheet

Set ws = Sheets("Request Log")
erow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

ws.Cells(erow, 1).Value = ComboBoxName.Value
ws.Cells(erow, 2).Value = Date
ws.Cells(erow, 3).Value = Time
ws.Cells(erow, 4).Value = DTPicker1.Value
ws.Cells(erow, 5).Value = DTPicker2.Value

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
You're welcome Raccoon. I'm glad that I was able to help.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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