+ Reply to Thread
Results 1 to 4 of 4

Repeating Macro

Hybrid View

  1. #1
    Dino
    Guest

    Repeating Macro

    Is there a way to have a macro repeat a specified number of times? For
    example, I have a spreadsheet that comes from my accounting software that
    has about 30,000 lines. Only the first, fourth, seventh etc line is needed.
    From the beginning, I need to move down a row, delete two rows, move down a
    row, delete two rows until the entire data is cleaned up. I can record the
    macro to delete the two lines, but I don't know how to make it repeat.
    Ideas?

    Thanks,
    Dino




  2. #2
    Anne Troy
    Guest

    Re: Repeating Macro

    Dino: Are the rows blank? If, for instance, column B is always blank in the
    first, fourth, seventh, then you can:
    Select column B.
    Hit Edit-->Go To-->Special, Blank cells, Ok.
    Hit Edit-->Delete.
    Choose Entire Rows. OK.

    ************
    Hope it helps!
    Anne Troy
    www.OfficeArticles.com
    Check out the NEWsgroup stats!
    Check out: www.ExcelUserConference.com

    "Dino" <dinolowe_nospam_@comcast.net> wrote in message
    news:emOySudMGHA.1488@TK2MSFTNGP14.phx.gbl...
    > Is there a way to have a macro repeat a specified number of times? For
    > example, I have a spreadsheet that comes from my accounting software that
    > has about 30,000 lines. Only the first, fourth, seventh etc line is
    > needed. From the beginning, I need to move down a row, delete two rows,
    > move down a row, delete two rows until the entire data is cleaned up. I
    > can record the macro to delete the two lines, but I don't know how to make
    > it repeat. Ideas?
    >
    > Thanks,
    > Dino
    >
    >
    >




  3. #3
    Norman Jones
    Guest

    Re: Repeating Macro

    Hi Dino.

    Try:

    '=============>>
    Public Sub TesterA001()
    Dim WB As Workbook
    Dim SH As Worksheet
    Dim LRow As Long
    Dim i As Long
    Dim CalcMode As Long

    Set WB = ActiveWorkbook '<<===== CHANGE
    Set SH = WB.Sheets("Sheet1") '<<===== CHANGE

    On Error GoTo XIT

    With Application
    CalcMode = .Calculation
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    End With

    LRow = Cells(Rows.Count, "A").End(xlUp).Row

    Select Case LRow Mod 3
    Case 0: LRow = LRow - 1
    Case 1: LRow = LRow - 2
    End Select

    For i = LRow To 1 Step -3
    Rows(i).Resize(2, 1).Delete
    Next i

    XIT:

    With Application
    .Calculation = CalcMode
    .ScreenUpdating = True
    End With

    End Sub
    '<<=============


    ---
    Regards,
    Norman


    "Dino" <dinolowe_nospam_@comcast.net> wrote in message
    news:emOySudMGHA.1488@TK2MSFTNGP14.phx.gbl...
    > Is there a way to have a macro repeat a specified number of times? For
    > example, I have a spreadsheet that comes from my accounting software that
    > has about 30,000 lines. Only the first, fourth, seventh etc line is
    > needed. From the beginning, I need to move down a row, delete two rows,
    > move down a row, delete two rows until the entire data is cleaned up. I
    > can record the macro to delete the two lines, but I don't know how to make
    > it repeat. Ideas?
    >
    > Thanks,
    > Dino
    >
    >
    >




  4. #4
    Norman Jones
    Guest

    Re: Repeating Macro

    Hi Dino,

    Change:

    > Rows(i).Resize(2, 1).Delete


    to

    Rows(i).Resize(2).Delete


    ---
    Regards,
    Norman



+ 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