Results 1 to 5 of 5

"Object required" error with VBA loop rows deleting

Threaded View

  1. #1
    Registered User
    Join Date
    07-22-2012
    Location
    POLAND
    MS-Off Ver
    Excel 2003
    Posts
    2

    "Object required" error with VBA loop rows deleting

    The macro below should remove rows with text in column "A" containing "1" digit(e.g. A1, AB1) and rows below it, if cell in column "A" is empty and cell in column "K" is not empty. When there is a row with "1" and one row below it- macro removes this row below, then the error appears: "object required" and a row with "1" is not removed. When there are only rows with "1" without these rows below - it is ok, the rows are removed.
    Someone helps?

    Sub planp()
    Dim n
    Dim eCell
    Dim eCell1
    Dim eCell2
    
    For n = 64 To 1 Step -1
    
    Set eCell = Worksheets("Arkusz4").Cells(n, 1)
    Set eCell1 = Worksheets("Arkusz4").Cells(n + 1, 1)
    Set eCell2 = Worksheets("Arkusz4").Cells(n + 1, 11)
    
    If Right(eCell.Value, 1) = "1" Then
    
    Do While eCell1.Value = "" And eCell2.Value <> ""
    Worksheets("Arkusz4").Rows(n + 1).Delete
    Loop
    Worksheets("Arkusz4").Rows(n).Delete
    End If
    Next
    
    End Sub
    Last edited by Cutter; 07-22-2012 at 08:50 AM. Reason: Added code tags

Thread Information

Users Browsing this Thread

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

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