VBA To Populate Cells in a pattern

mtagliaferri

Board Regular
Joined
Oct 27, 2004
Messages
156
I have a shift planner which I populate days OFF with the letter 'O and it formats the cell colour to blue.
I would like to populate the row with a specific patter of 28 days which is 5 On, 5 Off, 4 On, 5 Off, 5 On, 4 Off, therefore when the patter is OFF I would like to populate the cell with the letter 'O'
more specifically I need this pattern to be able to start from the selected cell and populate the rows from there onwards and for the remaining sheets.
E.G in the sheet October if I start from the 3rd which is F7 I need to start the pattern from that cell till end of October (Cell AH7) and then continue with the pattern in November (D7 - AG7) and then December (D7- AH7). If I start from January then it will populate all sheets to December.
Pic 01.jpg

The difficult part is the leap year, the sheet populates the calendar section based on the year, therefore I have the additional column in February in order to accommodate the leap year.
Pic 02.jpg


Any thoughts if this is achievable? If so how?
 
Valid point.... the best would be that the new pattern starts from the new selection. I did not think of that therefore it would need to first clear and then write 'O' following the pattern.
I think I could manually clear the the cell before running the code as a worse case scenario. the reason to populate automatically is do avoid errors entering the pattern.
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
That idea requires that the selected cell is the correct one for the beginning of the pattern. If you chose the 2nd cell that would be 5 on instead of the 1st 5 on you'd mess it all up. Methinks I'd check that the selected cell is at the proper spot for the sequence at the leftmost side of the sheet, or if the user is capable, have them select the beginning point of the pattern so that they could start at 4 on/off if they knew that was what they wanted. That would complicate things though and there might be an easier way to avoid starting out of sync.
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

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