Populating worksheet with a range of dates from a UserForm

shaeto

New Member
Joined
Jun 12, 2013
Messages
3
Greetings,

I'm making my way up slowly but surely to get better at VBA coding but the road is still long thus I humbly request for any assistance from your side :pray:

I actually have a worksheet as per below:
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Date[/TD]
[TD="align: center"]Item X[/TD]
[TD="align: center"]Item Y[/TD]
[TD="align: center"]Item Z[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
The sheet is populated with data from a UserForm with the following objects on it:
  • Start Date: (Label1) - Text box (TextBox1)
  • End date: (Label2) - Text Box: (TextBox2)
  • Item X: (Label3) - Text Box (TextBox3)
  • Item Y: (Label4) - Text Box (TextBox4)
  • Item Z: (Label5) - Text Box (TextBox5)
  • Save - (CommandButton1)

I actually can't get the VBA code right which will populate the worksheet as per below once I fill in the UserForm and hit the 'Save' button

[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]USERFORM[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Start Date: 01/01/2019 End Date: 01/03/2019

Item X: ABCD

Item Y: EFGH

Item Z: IJKL

SAVE
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Date[/TD]
[TD="align: center"]Item X[/TD]
[TD="align: center"]Item Y[/TD]
[TD="align: center"]Item Z[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]01/01/2019[/TD]
[TD="align: center"]ABCD[/TD]
[TD="align: center"]EFGH[/TD]
[TD="align: center"]IJKL[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]01/02/2019[/TD]
[TD="align: center"]ABCD[/TD]
[TD="align: center"]EFGH[/TD]
[TD="align: center"]IJKL[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]01/03/2019[/TD]
[TD="align: center"]ABCD[/TD]
[TD="align: center"]EFGH[/TD]
[TD="align: center"]IJKL[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Additionally if any date within the range is a Sunday, same must not be listed in the worksheet.

Finally in case the 'Start Date' and the 'End Date' are the same date, then only one row is to be filled.

That is:

[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]USERFORM[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Start Date: 01/11/2019 End Date: 01/11/2019

Item X: MNOP

Item Y: QRST

ItemZ: UVWA

SAVE[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD="align: center"]Date[/TD]
[TD="align: center"]Item X[/TD]
[TD="align: center"]Item Y[/TD]
[TD="align: center"]Item Z[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]01/01/2019[/TD]
[TD]ABCD[/TD]
[TD]EFGH[/TD]
[TD]IJKL[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]01/02/2019[/TD]
[TD]ABCD[/TD]
[TD]EFGH[/TD]
[TD]IJKL[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]01/03/2019[/TD]
[TD]ABCD[/TD]
[TD]EFGH[/TD]
[TD]IJKL[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]01/11/2019[/TD]
[TD]MNOP[/TD]
[TD]QRST[/TD]
[TD]UVWA[/TD]
[/TR]
</tbody>[/TABLE]


Thank you beforehand for your valuable help.

Cheers

Shameem
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,224,818
Messages
6,181,152
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