Consulting

Results 1 to 3 of 3

Thread: Object required error with VBA rows deleting

  1. #1
    VBAX Newbie
    Joined
    Jul 2012
    Posts
    1
    Location

    Object required error with VBA 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.


    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

  2. #2
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    attacch please a sample, I can not have errors

  3. #3
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    Solved on MrExcel.
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •