+ Reply to Thread
Results 1 to 8 of 8

Urgent Help Needed! - Deleting rows by multiple conditions

  1. #1
    Registered User
    Join Date
    06-06-2006
    MS-Off Ver
    2010, 365
    Posts
    39

    Question Urgent Help Needed! - Deleting rows by multiple conditions

    Hi,

    I am writing a code to delete rows from a sheet by matching array values with cells in a column. My code is not generating any error, but, it is also not deleting rows as well. Clearly, there is fundamentally wrong with my logic. PLEASE HELP!!!!

    Sub delRow()

    Dim myRange As Range

    Dim all As Range

    Dim b As Boolean

    Dim delArray As Variant

    Dim i As Integer

    delArray = Array("Niel", "Barry")


    For i = LBound(delArray) To UBound(delArray)

    If Range("oRange").Cells(17).Value = delArray(i) Then

    If b Then
    myRange = Range("oRange").CurrentRegion.Rows
    Set all = Application.Union(myRange, all)
    Else
    Set all = myRange
    b = True
    End If

    End If

    Next i

    If Not all Is Nothing Then all.EntireRow.Delete

    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Urgent Help Needed! - Deleting rows by multiple conditions

    can you attach a sample workbook?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Urgent Help Needed! - Deleting rows by multiple conditions

    I think you need this

    Please Login or Register  to view this content.
    Last edited by lancer102rus; 08-01-2014 at 04:15 AM.

  4. #4
    Registered User
    Join Date
    06-06-2006
    MS-Off Ver
    2010, 365
    Posts
    39

    Re: Urgent Help Needed! - Deleting rows by multiple conditions

    Hi nathansav,

    Attaching sample workbook for you.

    Quote Originally Posted by nathansav View Post
    can you attach a sample workbook?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-06-2006
    MS-Off Ver
    2010, 365
    Posts
    39

    Re: Urgent Help Needed! - Deleting rows by multiple conditions

    lancer102rus, tried using your code... but still, it doesn't work. You may check out the file that I recently uploaded above....

    Will be grateful if you could have a look at the code...

    Quote Originally Posted by lancer102rus View Post
    I think you need this

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Urgent Help Needed! - Deleting rows by multiple conditions

    Its your range

    oRange is A to C, but you are looking fro column 17 in there


    For Each iRng In Range("oRange").Columns(1).Cells

  7. #7
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Urgent Help Needed! - Deleting rows by multiple conditions

    why do you check cell #17? if your conditions in column #1
    just change "17" to "1" in my code

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Urgent Help Needed! - Deleting rows by multiple conditions

    Try the attached.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Hyderbad
    MS-Off Ver
    Excel 2003
    Posts
    122

    Smile Re: Urgent Help Needed! - Deleting rows by multiple conditions

    Hi,

    Please find the attachment.......

    FOR LOOP's i have renamed sheets names.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Merging Rows with multiple selections without deleting text, VBA may be needed
    By carlc711 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2013, 11:41 AM
  2. [SOLVED] Urgent help needed on multiple criteria matching
    By kalyanaasuri in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-07-2012, 05:05 PM
  3. Deleting rows in excel based on multiple conditions
    By tricket7 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-28-2012, 10:08 AM
  4. Replies: 5
    Last Post: 05-03-2005, 12:06 AM
  5. SUM based on multiple conditions - SORRY, URGENT!!!
    By marika1981 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-18-2005, 10:06 AM

Tags for this Thread

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