why is it if I try to set my work book or work sheets I cant use the set shortcut in my commands...
see below
see below
VBA Code:
Sub test()
Dim wb As Workbook
Dim ws As Worksheet
Dim myrange As Range
Set wb = ActiveWorkbook
Set ws = Worksheets("sheet1")
Set myrange = wb.ws.Range("K2:K15") 'doesn't work
Set myrange = ActiveWorkbook.Worksheets("sheet1").Range("K2:K15") 'does work
With wb.ws.Range("K2:K15") 'doesn't work
With myrange 'does work
.FormatConditions.Delete
.FormatConditions.AddUniqueValues
.FormatConditions(1).DupeUnique = xlDuplicate
.FormatConditions(1).Font.Color = -16776961
.FormatConditions(1).Font.Bold = True
End With
End Sub