Excelish12
New Member
- Joined
- Aug 24, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- 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
Example of the Table before the Buttons are used
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)
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
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
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!
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
Example of the Table before the Buttons are used
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")
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!