Good evening
I have a spreadsheet that tracks projects and hours allocated to them, It is a future planner so each week last week gets deleted and week twelve gets added. A lot of these projects are in schools and can only be carried out during the school holidays. I'd like to be able to highlight the columns which fall between these dates dynamically?
I have a formula that inputs the holiday "Name" on row 4 but I cannot work out a way to highlight the entire column if the dates in Row 5 fall between our holiday dates.
this is what I've tried so far which I realise if I could get it to work I would have to replicate it 12 times for each week. it highlights the selection irrespective of what dates are shown.
As always I'd be grateful for any advice, happy to desensitize the spreadsheet and post that if required.
I have a spreadsheet that tracks projects and hours allocated to them, It is a future planner so each week last week gets deleted and week twelve gets added. A lot of these projects are in schools and can only be carried out during the school holidays. I'd like to be able to highlight the columns which fall between these dates dynamically?
I have a formula that inputs the holiday "Name" on row 4 but I cannot work out a way to highlight the entire column if the dates in Row 5 fall between our holiday dates.
this is what I've tried so far which I realise if I could get it to work I would have to replicate it 12 times for each week. it highlights the selection irrespective of what dates are shown.
As always I'd be grateful for any advice, happy to desensitize the spreadsheet and post that if required.
VBA Code:
Sub Macro1()
Dim RNG1 As Range, RNG2 As Range
Dim dt As Variant
Dim SD As Variant
Dim FD As Variant
'
' Macro1 Macro
Set RNG1 = Range("C6:I6")
Set RNG2 = Range("P36:V36")
SD = Range("P36")
FD = Range("W36")
With Sheets("master Sheet")
For Each dt In RNG1
If dt.Value >= SD And dt.Value < FD Then
Range("C8:I31").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Color = -16776961
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Color = -16776961
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Color = -16776961
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Color = -16776961
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Else
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End If
Next dt
End With
Range("A1").Select
End Sub