I need the cells J8, J10, J12, J14 to change from a white interior to a gray pattern when the number in J4 is changed In other words when J4 changes to 2, J8 interior color changes when J4 is changed to 3 J10 then changes and the same for J12 and J14. Also in cell C4 if 5 is selected I need Cells I 16 and J16 to show with J16 interior to be white when the value is "5" in J4. When the workbook is reset for a new period I need the cells J8, J10, J12, J14 interior to be white until J4 is change from 1 to 2, etc with week 1 gray patterned. I have coded it but I cannot get week 4,5 to work properly, nor can I get the cells to change back to a white interior when the workbook is reset.
Here is my code:
Here is my code:
Code:
Private Sub Worksheet_Activate()
Me.ScrollArea = "A1:P25"
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
If Range("J4") = 1 Then
Range("J8").Select
ElseIf Range("J4") = 2 Then
Range("J10").Select
ElseIf Range("J4") = 3 Then
Range("J12").Select
ElseIf Range("J4") = 4 Then
Range("J14").Select
ElseIf Range("J4") = 5 Then
Range("J16").Select
End If
' GrossSalesCalc Macro
ActiveCell.FormulaR1C1 = _
"=SUM('STAGING AREA'!R[-5]C[-8],'STAGING AREA'!R[-3]C[-8],'STAGING AREA'!R[-2]C[-8],'STAGING AREA'!RC[-8])"
Range("J10").Select
ActiveCell.FormulaR1C1 = _
"=SUM('STAGING AREA'!R[-7]C[-6],'STAGING AREA'!R[-5]C[-6],'STAGING AREA'!R[-4]C[-6],'STAGING AREA'!R[-2]C[-6])"
Range("J12").Select
ActiveCell.FormulaR1C1 = _
"=SUM('STAGING AREA'!R[-9]C[-4],'STAGING AREA'!R[-7]C[-4],'STAGING AREA'!R[-6]C[-4],'STAGING AREA'!R[-4]C[-4])"
Range("J14").Select
ActiveCell.FormulaR1C1 = _
"=SUM('STAGING AREA'!R[-11]C[-2],'STAGING AREA'!R[-9]C[-2],'STAGING AREA'!R[-8]C[-2],'STAGING AREA'!R[-6]C[-2])"
Range("J16").Select
ActiveCell.FormulaR1C1 = _
"=SUM('STAGING AREA'!R[-13]C,'STAGING AREA'!R[-11]C,'STAGING AREA'!R[-10]C,'STAGING AREA'!R[-8]C)"
Range("J17").Select
End Sub
Private Sub CheckWeek()
'
If Range("J4").Value = 1 Then
Range("J8").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
Range("J10,J12,J14").Select
With Selection.Interior
.Pattern = xlGray50
.PatternColorIndex = 16
End With
Range("J8").Select
'
ElseIf Range("J4").Value = 2 Then
Range("J10").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
Range("J8,J12,J14").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlGray50
.PatternColorIndex = 16
End With
Range("J10").Select
'
ElseIf Range("J4").Value = 3 Then
Range("J12").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
Range("J8,J10,J14").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlGray50
.PatternColorIndex = 16
End With
Range("J12").Select
'
ElseIf Range("J4").Value = 4 Then
Range("J14").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
Range("J8,J10,J12").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlGray50
.PatternColorIndex = 16
End With
Range("J14").Select
'
ElseIf Range("J4").Value = 5 Then
Range("J8,J10,J12,J14").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlGray50
.PatternColorIndex = 16
End With
Range("J16").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
End If
End Sub
Private Sub DIMWEEK()
If Range("J4") = 5 Then
Call ShowWeek5
Else
Call NOShowWeek5
End If
End Sub
Private Sub ShowWeek5()
'
Range("J16").Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlGray50
.PatternColorIndex = 16
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 16
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 16
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = 16
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = 16
End With
End Sub
Private Sub NOShowWeek5()
'
Range("J16").Select
With Selection
.Interior.ColorIndex = 15
.Interior.Pattern = xlSolid
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
End With
'
End Sub