Macro to add coloured Border on column based on recurring dates

regan_2000

New Member
Joined
Mar 7, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi, Thank you for all your fantastic help and tips.

I want to be able to add a macro to an excel spreadsheet that adds a border on one side of a column that recurs every 14 days

From the image attached, I would like:
Think Blue line on the left hand side of the column
Recurring every 14 days (so every 14 columns) (it is between Wed and Thurs, every second week to display the payday)
Runs from Rows 1 to 6

Hope this is not too hard as it is a manual process for me currently

Thanks in advance
 

Attachments

  • Capture.PNG
    Capture.PNG
    24 KB · Views: 9

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi,
Try this

Sub Macro1()

For i = 1 To 100

If Weekday(ActiveSheet.Cells(1, i)) = 4 Then

ActiveSheet.Cells(1, i).Borders(xlDiagonalDown).LineStyle = xlNone
ActiveSheet.Cells(1, i).Borders(xlDiagonalUp).LineStyle = xlNone
ActiveSheet.Cells(1, i).Borders(xlEdgeLeft).LineStyle = xlNone
ActiveSheet.Cells(1, i).Borders(xlEdgeTop).LineStyle = xlNone
ActiveSheet.Cells(1, i).Borders(xlEdgeBottom).LineStyle = xlNone
With ActiveSheet.Cells(1, i).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ThemeColor = 5
.TintAndShade = -0.249946592608417
.Weight = xlMedium
End With

End If
Next i

End Sub



formatcellwithdayofweek.xlsm
 
Upvote 0
Select the first Thursday in your row of dates that needs the left boarder then run this macro
VBA Code:
Sub BoarderEvery14thColumn()
    
    Dim i As Long, rw As Long
    Dim startCol As Long, lastCol As Long
   
rw = Selection.Row
startCol = Selection.Column
lastCol = Cells(rw, Columns.Count).End(xlToLeft).Column

For i = startCol To lastCol Step 14
    With Cells(1, i).Resize(6).Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Color = vbBlue
        .TintAndShade = 0
        .Weight = xlThick
    End With
Next i

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,089
Latest member
ikke

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