I am working with daily data that recorded 31 days of data per multiple stations and I need a VBA code to remove leap year days. I have a list of dates of data recorded and a l
Modified version of my answer from This Question
Sub Sample()
Dim StartingScreenUpdateValue As Boolean
Dim StartingEventsValue As Boolean
Dim StartingCalculations As XlCalculation
With Application
StartingScreenUpdateValue = .ScreenUpdating
StartingEventsValue = .EnableEvents
StartingCalculations = .Calculation
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Dim varTestValues As Variant
varTestValues = Workbooks("LeapYears.xlsx").Sheets(1).Range("C2:C90")
Rows(1).Insert
[A1].FormulaR1C1 = "TempHeader1"
[A1].AutoFill Destination:=Range("A1:H1"), Type:=xlFillDefault
Range("D1").AutoFilter Field:=4, Criteria1:=Application.Transpose(varTestValues), Operator:=xlFilterValues
Range("D2", Range("D" & Rows.Count).End(xlUp)) _
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
ActiveSheet.AutoFilterMode = False
Rows(1).Delete
With Application
.ScreenUpdating = StartingScreenUpdateValue
.EnableEvents = StartingEventsValue
.Calculation = StartingCalculations
End With
End Sub
NOTE: This code runs assuming your data has headers if it does not please advise.
REMEMBER Always run any code on a copy of your data and not your actual data until you are confident that it is working 100%.