+ Reply to Thread
Results 1 to 3 of 3

trouble looping through column with data qualifier

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-12-2013
    Location
    chicago, illinois
    MS-Off Ver
    Excel 2010
    Posts
    109

    trouble looping through column with data qualifier

    hi all! i am using the code below to look at column O and determing if the characters "AB" are somewhere in the cell. (data might be AB, ABCD, ABD, ABC, CDAB, etc)
    then if that is true i need to look in the cell just to the right of it (same row) where there will be only 2 choices that can be in that cell, AB or CD. if AB is found in column O and AB is found in column P then the row can stay, likewise for CD and CD. otherwise, say, if AB is found in column O and CD is found in column P then that row has to go!

    i am receiving an Application-defined or object-defined error (1004) on the IF statement line

    Private Sub CommandButton2_Click()
    Dim i As Integer
    numrows = Range("o5", Range("o5").End(xlDown)).Rows.Count
    
    Range("o5").Select
    
    
    
    For i = 1 To numrows
    If Cells(i, 0).Value = "*IN" And Cells(i, 0).Offset(0, 1).Value = Not ("IN") Then  ' ERRORS HERE <<<<<<<<<<<
    Selection.EntireRow.Delete
    
    ElseIf Cells(i, 0).Value = "*SH*" And Cells(i, 0).Offset(0, 1).Value = Not ("CN") Then
    Selection.EntireRow.Delete
    End If
    
    Next i
    
    End Sub

    what am i doing wrong??
    thanks!!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: trouble looping through column with data qualifier

    Perhaps "O" instead of 0 in Cells(i,0) etc?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    09-12-2013
    Location
    chicago, illinois
    MS-Off Ver
    Excel 2010
    Posts
    109

    Re: trouble looping through column with data qualifier

    i think that did it :D looks to work almost like i want it to lol....at least i'm not getting errors.

    thanks!!

+ 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. [SOLVED] Invalid Qualifier to a Valid Qualifier (Application)
    By exceltabz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2014, 11:31 AM
  2. [SOLVED] Trouble Looping Multiple Column Arrays
    By D.L. in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-23-2012, 03:32 AM
  3. [SOLVED] Trouble Looping Macro
    By zhb12810 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-17-2012, 02:09 PM
  4. [SOLVED] Trouble with looping
    By Rbp9ad in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-07-2005, 09:05 PM

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