Hi everyone,
The code below aims to remove every row when the value in column M is 'Non Available' from sheet 'Summary' and put the entire row in another sheet 'Summarybis'. I'd like to add one argument in the countif function such as also removing every row with value in column M as 'To investigate' and also put it in the sheet 'Summarybis'. How can I do except by creating a new code and replacing what I need?
Finally, I think the above code is not entirely defined because it may happen that no output is produced (nothing is filled in sheet 'Summarybis'). What am I missing?
Thank you so much in advance !
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">Sub removing_rows()
Dim Check As Range, lastrow As Long, lastrow2 As Long
lastrow = Worksheets("Summary").UsedRange.Rows.Count
lastrow2 = Worksheets("Summarybis").UsedRange.Rows.Count
If lastrow2 = 1 Then
lastrow2 = 0
Else
End If
Do While Application.WorksheetFunction.CountIf(Range("M:M"), "Non Available") > 0
Set Check = Range("M2:M" & lastrow)
For Each Cell In Check
If Cell = "Non Available" Then
Cell.EntireRow.Copy Destination:=Worksheets("Summarybis").Range("A" & lastrow2 + 1)
Cell.EntireRow.Delete
lastrow2 = lastrow2 + 1
Else:
End If
Next
Loop
End Sub
</code>
The code below aims to remove every row when the value in column M is 'Non Available' from sheet 'Summary' and put the entire row in another sheet 'Summarybis'. I'd like to add one argument in the countif function such as also removing every row with value in column M as 'To investigate' and also put it in the sheet 'Summarybis'. How can I do except by creating a new code and replacing what I need?
Finally, I think the above code is not entirely defined because it may happen that no output is produced (nothing is filled in sheet 'Summarybis'). What am I missing?
Thank you so much in advance !
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">Sub removing_rows()
Dim Check As Range, lastrow As Long, lastrow2 As Long
lastrow = Worksheets("Summary").UsedRange.Rows.Count
lastrow2 = Worksheets("Summarybis").UsedRange.Rows.Count
If lastrow2 = 1 Then
lastrow2 = 0
Else
End If
Do While Application.WorksheetFunction.CountIf(Range("M:M"), "Non Available") > 0
Set Check = Range("M2:M" & lastrow)
For Each Cell In Check
If Cell = "Non Available" Then
Cell.EntireRow.Copy Destination:=Worksheets("Summarybis").Range("A" & lastrow2 + 1)
Cell.EntireRow.Delete
lastrow2 = lastrow2 + 1
Else:
End If
Next
Loop
End Sub
</code>