I need to separate numerous data entries by year, so I need to find all entries containing the year in question, copy the cell year is listed in as well as 2 cells on either side, and paste the 5 cells into a new spreadsheet. Here's the code I have closest to working:
Cells.Find(What:="2000", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True, _
SearchFormat:=False).Activate
ActiveCell.Offset(0, -2).Resize(1, 5).Copy
Sheets.Add After:=Sheets("2000")
ActiveSheet.Paste
Worksheets("Sheet1").Activate
This finds the first case, but I'm having trouble constructing a loop that will do this (particularly the offset) for all found values. There are dates in multiple columns, so I can't just copy the entire row, either.
Cells.Find(What:="2000", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True, _
SearchFormat:=False).Activate
ActiveCell.Offset(0, -2).Resize(1, 5).Copy
Sheets.Add After:=Sheets("2000")
ActiveSheet.Paste
Worksheets("Sheet1").Activate
This finds the first case, but I'm having trouble constructing a loop that will do this (particularly the offset) for all found values. There are dates in multiple columns, so I can't just copy the entire row, either.