Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. Sub showEightmonth(ws, colName, colIndex)
  2. Dim RowCount As Integer
  3. ws.Activate
  4. MsgBox ws.Name
  5. RowCount = Cells(Rows.Count, colIndex).End(xlUp).Row
  6. Set Rng = Range(colName & "1:" & colName & RowCount)
  7.  
  8. If ws.AutoFilterMode = True Then
  9. ws.AutoFilter.ShowAllData
  10. End If
  11.  
  12. Rng.Select
  13. Rng.NumberFormat = "mm/dd/yyyy hh:mm:ss"
  14. d = Format(DateAdd("m", -8, Date), "mm/dd/yyyy 07:00:00")
  15. Range(colName & "1").AutoFilter Field:=colIndex, Criteria1:="<" & d
  16. RowCount = Cells(Rows.Count, colIndex).End(xlUp).SpecialCells(xlCellTypeVisible).Row
  17. 'Delete filtered row if RowCount > 1, as row 1 is the header row
  18. If RowCount > 1 Then
  19. delRow = colName & "2:" & colName & RowCount
  20. ActiveSheet.Range(delRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
  21. End If
  22. If ws.AutoFilterMode = True Then
  23. ws.AutoFilter.ShowAllData
  24. End If
  25.  
  26. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement