Excelish12

New Member
Joined
Aug 24, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi

I am trying to automate a workbook that uses just a few entered fields to populate the correct information and formulas in columns and cells in the table below based on 2 button clicks.
User enters start and end date, and then time ranges for each day in the top of the worksheet. The Columns and Day of Week Start are calculated. The Columns calculation is used to drive the number of columns to insert between start and end date and the day of week start is used for a check function between the value calculated and the first start date day row in the table.

Example of the user entry in top of sheet
1661338151590.png


Example of the Table before the Buttons are used
1661338239438.png


Button 1 needs to do the following:
1 - insert the correct number of blank columns between the start and end date based on the calculated field columns C15 (I have done the VBA on this and it is working)

VBA Code:
Sub InsertMultipleColumns()

Inserted_Columns = Range("C15").Value

For i = 1 To Inserted_Columns
    ActiveSheet.Range("J26").EntireColumn.Insert
 
Next i

End Sub


2 - needs to add the missing dates in the blank columns at an increment of 1 day until it gets to end date. So 2022/08/27 and 2022/08/28 etc.
3 - needs to add the days formula above the dates
Excel Formula:
TEXT($I$27,"dddd")
in the blank row above dates. So Saturday, Sunday etc based on the date.

Button 2 needs to do the following:
1 - Insert the time range from user selection based on the day of the week. The formula is using an ifs statement to return the time range from user entry into every cell below the dates that are on those days. So if a person is not working from a monday to a thursday the table will not contain any time ranges on those days in the date range
Excel Formula:
=IFS($I$26="Monday",$C$17,$I$26="Tuesday",$C$18,$I$26="Wednesday",$C$19,$I$26="Thursday",$C$20,$I$26="Friday",$C$21,$I$26="Saturday",$C$22,$I$26="Sunday",$C$23)

There are scenarios when the times will not be constant so I have chosen to use Insert Times as a button on its own so that the user does not have to first delete formulas.

I cannot find any VBA that is doing exactly this and my VBA knowledge is limited to changing variables in simple macros not writing code.

Please help!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,214,983
Messages
6,122,592
Members
449,089
Latest member
Motoracer88

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