Hello: I have part of a macro that needs to clean up cells and replace the bad data with the good data. I'm using a loop nested if else, but is there a more efficient way? This looks cumbersome. Any help would be appreciated . Thank you!
Code:
Sub cleandata()
Dim i As Long
Dim DataValue As Variant
Dim LastRow As Long
Dim StartRow As Long
StartRow = 7
LastRow = Cells(StartRow, 6).End(xlDown).Row
For i = StartRow To LastRow
DataValue = Cells(i, 6).Value
If InStr(1, Cells(i, 6), "Apples Today") = 1 Then
Cells(i, 6) = "Apple"
Else
If InStr(1, Cells(i, 6), "Oranges Not Good") = 1 Then
Cells(i, 6) = "Oranges"
Else
If InStr(1, Cells(i, 6), "Blue") = 1 Then
Cells(i, 6) = "Blueberries"
Else
If InStr(1, Cells(i, 6), "Apples Tomorrow") = 1 Then
Cells(i, 6) = "Apples plus 2"
Else
If InStr(1, Cells(i, 6), "Fruit") = 1 Then
Cells(i, 6) = "Fruit Stock"
Else
If InStr(1, Cells(i, 6), "Bananas") = 1 Then
Cells(i, 6) = "Ban"
Else
End If
End If
End If
End If
End If
End If
Next i
End Sub