+ Reply to Thread
Results 1 to 3 of 3

Delete rows. Inputbox multiple criteria

Hybrid View

vbanooby Delete rows. Inputbox... 06-29-2011, 01:43 PM
vbanooby Re: Delete rows. Inputbox... 06-29-2011, 01:48 PM
vbanooby Re: Delete rows. Inputbox... 07-20-2011, 09:25 AM
  1. #1
    Registered User
    Join Date
    06-29-2011
    Location
    Sedgley
    MS-Off Ver
    Excel 2003
    Posts
    3

    Delete rows. Inputbox multiple criteria

    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?
    Last edited by Paul; 06-29-2011 at 01:46 PM. Reason: Added code tags for new user; please do this yourself in the future.

  2. #2
    Registered User
    Join Date
    06-29-2011
    Location
    Sedgley
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Delete rows. Inputbox multiple criteria

    Sorry will do

  3. #3
    Registered User
    Join Date
    06-29-2011
    Location
    Sedgley
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Delete rows. Inputbox multiple criteria

    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.

    Code:

    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?
    Last edited by Paul; 06-29-2011 at 12:46 PM. Reason: Added code tags for new user; please do this yourself in the future.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1