Hello,
I'm trying to delete some rows from my data-set depending on what values certain cells contains (see code below).
It works fine if the cell is 3, the macro returns the correct values - but for the rest of the cases, the rows won't delete.
(for the reccord, I don't know for certain if the rows are deleting for the case 3, and not value 133 or 148 statement)
Any suggestions?
Best Regards,
Kasper
Edit* sorry for the short title, wrote it as a temporary title but forgot to change it before posting. Cant seem to change the title after posting
I'm trying to delete some rows from my data-set depending on what values certain cells contains (see code below).
It works fine if the cell is 3, the macro returns the correct values - but for the rest of the cases, the rows won't delete.
(for the reccord, I don't know for certain if the rows are deleting for the case 3, and not value 133 or 148 statement)
VBA Code:
LastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
Dim y As Integer
For y = 2 To LastRow
Select Case ws.Cells(y, 2)
Case "0", "1", "4", "8", "9", "53"
ws.Cells(y, 2).EntireRow.Delete Shift:=xlUp
Case "3"
If ws.Cells(y, 6).Value = "133" Or ws.Cells(y, 6).Value = "148" Then
ws.Cells(y, 2) = "J3"
Else
If ws.Cells(y, 6).Value = "139" Or ws.Cells(y, 6).Value = "354" Then
ws.Cells(y, 2) = "JC"
Else
ws.Cells(y, 2).EntireRow.Delete Shift:=xlUp
End If
End If
End Select
Next y
Any suggestions?
Best Regards,
Kasper
Edit* sorry for the short title, wrote it as a temporary title but forgot to change it before posting. Cant seem to change the title after posting