Origamifan92
New Member
- Joined
- Apr 9, 2019
- Messages
- 7
I have some code that I'm trying to simplify, shown below. The overall macro is used to clear several sheets but one, sort all rows in the filled sheet, then copy and paste from one sheet to another according to values in a column. It works quickly and well, sorting about 70 lines in under 15 seconds, but is rather redundant. I've included an example showing how it's redundant. The code is basic enough to check for a value, then copy the line and paste in another sheet, but I'm wondering if there's a way to change it that, rather than have several lines and several IF statements, it's possible to condense the whole thing that it will alternate the desired checked value and sheets.
Code:
'Begin one sort loop
If check_value = "Administrative" Then
ActiveCell.EntireRow.Copy
Sheets("Admin").Select
RowCount = Cells(Cells.Rows.Count, "a").End(xlUp).Row + 1
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste
Application.ScreenUpdating = False
Columns(6).EntireColumn.Delete
Application.ScreenUpdating = False
Sheets("Master").Select
Application.ScreenUpdating = False
End If
'End one sort loop
If check_value = "Care Mgmnt" Then
ActiveCell.EntireRow.Copy
Sheets("Care Mgmnt").Select
RowCount = Cells(Cells.Rows.Count, "a").End(xlUp).Row + 1
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste
Application.ScreenUpdating = False
Columns(6).EntireColumn.Delete
Application.ScreenUpdating = False
Sheets("Master").Select
Application.ScreenUpdating = False
End If
Last edited by a moderator: