Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,533
- Office Version
- 365
- 2016
- Platform
- Windows
I am having an issue here with my sub commands being applied to the correct worksheet.
The code in green adds two new worksheets to my workbook. CUE and WPL
Oddly ... despite the code 'With Worksheets("WPL")' , the code in red is performed on worksheet CUE, while the code in blue, is performed in worksheet WPL.
If I don't add worksheet CUE to the workbook, it works.
Is anyone able to spot where I've messed up?
Rich (BB code):
Worksheets.Add(After:=Worksheets(13)).Name = "WPL"
Worksheets.Add(After:=Worksheets(13)).Name = "CUE"
'** POPULATE WORKSHEETS
.Range("H12") = "Groom"
.Range("I12") = "Prepare"
.Range("J12") = "Signature"
.Range("K12") = "Lights On"
.Range("L12") = "Lights Off"
.Range("M12") = "1"
.Range("N12") = "2"
.Range("O12") = "3"
.Range("P12") = "4"
.Range("Q12") = "Close"
If .FilterMode Then .ShowAllData
llastrow = .Range("R" & Rows.Count).End(xlUp).Row
'WPL
wshvar.Range("I27") = Worksheets("Staff").Range("B10")
With .Range("A12:R" & llastrow)
.AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=wshvar.Range("I28:R38"), _
Unique:=False
On Error Resume Next
End With
Worksheets("MasterWKSH").Range("A1:R300").Copy
With Worksheets("WPL")
With Range("A1")
.PasteSpecial xlPasteColumnWidths
.PasteSpecial xlPasteAll
End With
llastrow = .Range("R" & Rows.Count).End(xlUp).Row
.Range("M1") = Format(wshcore.Range("B2"), "dddd, mmmm dd, yyyy")
.Range("M4") = wshvar.Range("I27")
.Range("L4") = Application.VLookup(.Range("K4"), wshstaff.Range("L4:M20"), 2, False)
.Range("P4") = Application.VLookup("WPL1", wshcore.Range("BA:DJ"), 58, False)
.Range("M5") = Format(Application.VLookup("WPL1", wshcore.Range("BA:DJ"), 61, False), "h:mmA/P") & " - " & Format(Application.VLookup("WPL1", wshcore.Range("BA:DJ"), 62, False), "h:mmA/P")
.Range("P5") = Application.VLookup("WPL1", wshcore.Range("BA:DJ"), 59, False) & "-" & Application.VLookup("WPL1", wshcore.Range("BA:DJ"), 60, False)
With Range("H13:Q" & llastrow)
.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=varhold!$I$27"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0.499984740745262
End With
.FormatConditions(1).StopIfTrue = False
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=varhold!$I$27"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With
The code in green adds two new worksheets to my workbook. CUE and WPL
Oddly ... despite the code 'With Worksheets("WPL")' , the code in red is performed on worksheet CUE, while the code in blue, is performed in worksheet WPL.
If I don't add worksheet CUE to the workbook, it works.
Is anyone able to spot where I've messed up?