VBA that distributes dates along the year based on a schedule

Daniel Kimathi

New Member
Joined
Oct 13, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi,
How can I create a VBA for a preventive maintenance that distributes dates along the year based on a schedule e.g. daily, weekly, monthly etc. I am looking to Mark an "X" and also do conditional formatting for each cell marked "x" The Columns are
A - Machine Name
B - Work Instruction
C- Scheduled Frequency
D - Last Maintenance Date
E moving forward - days of the year within which maintenance is required to be done.

Machine Name
Work instruction
Schedule Frequency
Last Maintenance Date
1/10/20212/10/20213/10/20214/10/2021
Cutterreplace the bladesweekly13/10/2021
Replace the Cam wheelsMonthly29/9/2021
Check the Vacuum TubesDaily13/10/2021
OpenerCheck The SpringsDaily13/10/2021
Check the Arm Barweekly10/10/2021
Replace the main BearingAnnually6/6/2021
Grease the lower cam shaft 6 Months6/6/2021
. An example of such a table is shown below
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hello Daniel Kimathi and welcome to the forum. You might try something like the code below which places an x every 7 days (weekly) and then modify it for your requirements. Hope this helps get you started.

VBA Code:
Sub Weekly()
i = 5
    While i < 366 'Runs for about one year
        Cells(2, i).Value = "X"
        i = i + 7
    Wend
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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