+ Reply to Thread
Results 1 to 3 of 3

Delete specific rows, creating range and criteria using inputbox

  1. #1
    Registered User
    Join Date
    03-04-2008
    Location
    Abington, Pa
    Posts
    3

    Delete specific rows, creating range and criteria using inputbox

    Hello All,
    I am trying to build a macro that would delete specific rows depending on a range and criteria created, and selected by using inputbox method. I have it partially working, but cant get past this point. I greatly appreciate any asistance you could provide. I am sure that I do not need all the code below. Thanks in advance.,...G


    Sub DeleteRows()
    Dim r As Integer
    Dim totalR As Integer
    Dim question1 As String
    Dim question2 As String
    Dim question3 As String
    Dim mySearch As String
    Dim cell3 As Variant
    Dim BadWord As Range
    Dim cell1 As Range
    Dim cell2 As Range
    Dim cell4 As Range
    Dim allCells As Range
    totalR = Selection.Rows.Count
    question1 = "What cell would you like to start with?"
    question2 = "What what cell would you like to end with?"
    question3 = "Please enter search word."
    mySearch = cell3
    Set cell1 = Application.InputBox(prompt:=question1, _
    Title:="Range to Search", Type:=8)
    Set cell2 = Application.InputBox(prompt:=question2, _
    Title:="Range to Search", Type:=8)
    cell1.Value = cell1.Value
    cell3 = InputBox(prompt:=question3, _
    Title:="Search word or phrase")
    Set allCells = Range(cell1, cell2)
    allCells.Value = allCells.Value
    For Each cell1 In allCells
    If allCells.Value <> cell3.Value Then
    ActiveCell.EntireRow.Select
    Selection.EntireRow.Delete
    End If
    Next
    end sub

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    You could use a refedit control on a userform to select the range. Just a thought!
    Here is some modified code for you.

    Please Login or Register  to view this content.
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

  3. #3
    Registered User
    Join Date
    03-04-2008
    Location
    Abington, Pa
    Posts
    3

    Thank you

    Thanks for your kind assistance!

+ 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