Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub showEightmonth(ws, colName, colIndex)
- Dim RowCount As Integer
- ws.Activate
- MsgBox ws.Name
- RowCount = Cells(Rows.Count, colIndex).End(xlUp).Row
- Set Rng = Range(colName & "1:" & colName & RowCount)
- If ws.AutoFilterMode = True Then
- ws.AutoFilter.ShowAllData
- End If
- Rng.Select
- Rng.NumberFormat = "mm/dd/yyyy hh:mm:ss"
- d = Format(DateAdd("m", -8, Date), "mm/dd/yyyy 07:00:00")
- Range(colName & "1").AutoFilter Field:=colIndex, Criteria1:="<" & d
- RowCount = Cells(Rows.Count, colIndex).End(xlUp).SpecialCells(xlCellTypeVisible).Row
- 'Delete filtered row if RowCount > 1, as row 1 is the header row
- If RowCount > 1 Then
- delRow = colName & "2:" & colName & RowCount
- ActiveSheet.Range(delRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
- End If
- If ws.AutoFilterMode = True Then
- ws.AutoFilter.ShowAllData
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement