+ Reply to Thread
Results 1 to 5 of 5

Using And Function

  1. #1
    Forum Contributor
    Join Date
    10-23-2003
    Posts
    141

    Using And Function

    Does anyone have suggestions for a Macro that would look in a spreadsheet with approximately 10,000 lines and:

    If column D ="220" AND Column I = "January" AND Column K = "0500" THEN
    Delete the entire row.

    Any help would be greatly appreciated.

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello SteveB,

    Here is a macro that will do want you want.

    Public Sub ClearSpecialRows()

    Dim Row As Long

    Do
    Row = Row + 1
    With ActiveSheet
    If .Cells(Row, "A").Value = "220" Then
    If .Cells(Row, "I").Value = "January" And .Cells(Row, "K").Value = "0500" Then
    .Cells(Row, "A").EntireRow.Delete(xlShiftUp)
    Row = Row - 1
    End If
    End If
    Loop While .Cells(Row, "A").Value <> ""
    End With

    End Sub


    This should getyou started,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    10-23-2003
    Posts
    141
    Thanks Leith, I appreciate it!

    I tried your example & keep getting "Loop without Do". Am I missing something.

    Thanks for your help, I appreciate it!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Steve,

    Sorry for the typo. move the With ActiveSheet statement above Do.
    That should clear up the problem.

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    10-23-2003
    Posts
    141
    Thanks Leith!

    The Macro worked perfect, this is a HUGE time saver!

    I really appreciate your help!

+ 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