This code works but is slow and cumber sum, i wondered if there is a faster way of doing this or at least cutting the code down.
With "curCell" i have to keep selecting the cell from which to start from as a place marker. The value it is looking for is in column "O" but the value it needs to continue is in column "C".
Sub Clean()
' This code will remove any archived data from the array.
Workbooks("Slot Array3.5.xls").Worksheets("Master").Activate
Sheets("Master").UnProtect Password = WorkBooks("Slot Array 3.5.xls").WorkSheets("Intro").Range("U2")
Range("C5").Select
' Looks in the Slot Array "Master" sheet for outdated listings,
' removes each listing and places a counter in column "P", once completed removes the counter
For Each curCell In Range("C5:C5004").Cells
If curCell.Offset(0, 10).Value = "4" Then
curCell.Offset(0, 1).ClearContents
curCell.Offset(0, 11).Value = "1"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "1" Then
curCell.Offset(0, 3).ClearContents
curCell.Offset(0, 11).Value = "2"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "2" Then
curCell.Offset(0, 5).ClearContents
curCell.Offset(0, 11).Value = "3"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "3" Then
curCell.Offset(0, 6).ClearContents
curCell.Offset(0, 11).Value = "4"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "4" Then
curCell.Offset(0, 7).ClearContents
curCell.Offset(0, 11).Value = "5"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "5" Then
curCell.Offset(0, 8).ClearContents
curCell.Offset(0, 11).Value = "6"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "6" Then
curCell.Offset(0, 9).ClearContents
curCell.Offset(0, 11).Value = "7"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "7" Then
curCell.Offset(0, 0).ClearContents
curCell.Offset(0, 11).Value = "8"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "8" Then
curCell.Offset(0, 10).ClearContents
curCell.Offset(0, 11).ClearContents
End If
Next curCell
End Sub
With "curCell" i have to keep selecting the cell from which to start from as a place marker. The value it is looking for is in column "O" but the value it needs to continue is in column "C".
Sub Clean()
' This code will remove any archived data from the array.
Workbooks("Slot Array3.5.xls").Worksheets("Master").Activate
Sheets("Master").UnProtect Password = WorkBooks("Slot Array 3.5.xls").WorkSheets("Intro").Range("U2")
Range("C5").Select
' Looks in the Slot Array "Master" sheet for outdated listings,
' removes each listing and places a counter in column "P", once completed removes the counter
For Each curCell In Range("C5:C5004").Cells
If curCell.Offset(0, 10).Value = "4" Then
curCell.Offset(0, 1).ClearContents
curCell.Offset(0, 11).Value = "1"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "1" Then
curCell.Offset(0, 3).ClearContents
curCell.Offset(0, 11).Value = "2"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "2" Then
curCell.Offset(0, 5).ClearContents
curCell.Offset(0, 11).Value = "3"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "3" Then
curCell.Offset(0, 6).ClearContents
curCell.Offset(0, 11).Value = "4"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "4" Then
curCell.Offset(0, 7).ClearContents
curCell.Offset(0, 11).Value = "5"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "5" Then
curCell.Offset(0, 8).ClearContents
curCell.Offset(0, 11).Value = "6"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "6" Then
curCell.Offset(0, 9).ClearContents
curCell.Offset(0, 11).Value = "7"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "7" Then
curCell.Offset(0, 0).ClearContents
curCell.Offset(0, 11).Value = "8"
End If
Range("C5").Select
If curCell.Offset(0, 11).Value = "8" Then
curCell.Offset(0, 10).ClearContents
curCell.Offset(0, 11).ClearContents
End If
Next curCell
End Sub