Hi guys,
I have been asked to a make a spreadsheet to quickly sort our stock.
I was required to delete any rows that did not match the search criteria.
eg.
05-40
05-41
05-42
05-43
*we want to save the rows containg 05-41 (for example)
I achieved this and was super chuffed with myself.
Sub delete_It()
Sheets("Report Sheet").Select
Dim MyRange1 As Range
Dim MyRange As Range
Dim strToDelete As String
strToDelete = InputBox("What Sub-Category do you want?", "Delete Rows")
Application.ScreenUpdating = False
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Set MyRange = Range("B2:B" & lastrow)
For Each c In MyRange
If InStr(1, UCase(c.Value), strToDelete, 0) = False Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
If Not MyRange1 Is Nothing Then
MyRange1.Delete
End If
Range("A2").Select
End Sub
however as soon as the boss looked at it he said "great, but can you make it save multiple criteria from the inputbox?"
*so they now want to save all the 05-41 AND 05-42 (for example)
I have no clue how to do this...... can anybody help please?
Bookmarks