+ Reply to Thread
Results 1 to 4 of 4

Loop Macro?

  1. #1
    Carmen
    Guest

    Loop Macro?

    I am trying to get the following macro to loop until reaching the end of the
    data (length will not be standard every time). But when I run, it gets stuck
    - any suggestions?

    Thanks

    ActiveCell.Rows("1:1").EntireRow.Select
    Selection.Insert Shift:=xlDown
    ActiveCell.Select
    ActiveCell.FormulaR1C1 = "#"
    ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
    Selection.Insert Shift:=xlDown
    ActiveCell.Offset(-1, 1).Range("A1").Select
    Selection.Cut
    ActiveCell.Offset(1, -1).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(1, 0).Range("A1").Select
    Do Until ActiveCell.Value = ""
    Loop



    End Sub


  2. #2
    Bob Phillips
    Guest

    Re: Loop Macro?

    which bit do you want to loop around?

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Carmen" <[email protected]> wrote in message
    news:[email protected]...
    > I am trying to get the following macro to loop until reaching the end of

    the
    > data (length will not be standard every time). But when I run, it gets

    stuck
    > - any suggestions?
    >
    > Thanks
    >
    > ActiveCell.Rows("1:1").EntireRow.Select
    > Selection.Insert Shift:=xlDown
    > ActiveCell.Select
    > ActiveCell.FormulaR1C1 = "#"
    > ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
    > Selection.Insert Shift:=xlDown
    > ActiveCell.Offset(-1, 1).Range("A1").Select
    > Selection.Cut
    > ActiveCell.Offset(1, -1).Range("A1").Select
    > ActiveSheet.Paste
    > ActiveCell.Offset(1, 0).Range("A1").Select
    > Do Until ActiveCell.Value = ""
    > Loop
    >
    >
    >
    > End Sub
    >




  3. #3
    David
    Guest

    RE: Loop Macro?

    Hi,
    Don't know what you have as far as data goes, but the loop needs to start ot
    the top. This is your code with one line moved to the top.
    Thanks,

    > Do Until ActiveCell.Value = ""


    > ActiveCell.Rows("1:1").EntireRow.Select
    > Selection.Insert Shift:=xlDown
    > ActiveCell.Select
    > ActiveCell.FormulaR1C1 = "#"
    > ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
    > Selection.Insert Shift:=xlDown
    > ActiveCell.Offset(-1, 1).Range("A1").Select
    > Selection.Cut
    > ActiveCell.Offset(1, -1).Range("A1").Select
    > ActiveSheet.Paste
    > ActiveCell.Offset(1, 0).Range("A1").Select
    > Loop



    "Carmen" wrote:

    > I am trying to get the following macro to loop until reaching the end of the
    > data (length will not be standard every time). But when I run, it gets stuck
    > - any suggestions?
    >
    > Thanks
    >
    > ActiveCell.Rows("1:1").EntireRow.Select
    > Selection.Insert Shift:=xlDown
    > ActiveCell.Select
    > ActiveCell.FormulaR1C1 = "#"
    > ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
    > Selection.Insert Shift:=xlDown
    > ActiveCell.Offset(-1, 1).Range("A1").Select
    > Selection.Cut
    > ActiveCell.Offset(1, -1).Range("A1").Select
    > ActiveSheet.Paste
    > ActiveCell.Offset(1, 0).Range("A1").Select
    > Do Until ActiveCell.Value = ""
    > Loop
    >
    >
    >
    > End Sub
    >


  4. #4
    Carmen
    Guest

    RE: Loop Macro?

    Thank You so much! This is exactly what I needed.

    "David" wrote:

    > Hi,
    > Don't know what you have as far as data goes, but the loop needs to start ot
    > the top. This is your code with one line moved to the top.
    > Thanks,
    >
    > > Do Until ActiveCell.Value = ""

    >
    > > ActiveCell.Rows("1:1").EntireRow.Select
    > > Selection.Insert Shift:=xlDown
    > > ActiveCell.Select
    > > ActiveCell.FormulaR1C1 = "#"
    > > ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
    > > Selection.Insert Shift:=xlDown
    > > ActiveCell.Offset(-1, 1).Range("A1").Select
    > > Selection.Cut
    > > ActiveCell.Offset(1, -1).Range("A1").Select
    > > ActiveSheet.Paste
    > > ActiveCell.Offset(1, 0).Range("A1").Select
    > > Loop

    >
    >
    > "Carmen" wrote:
    >
    > > I am trying to get the following macro to loop until reaching the end of the
    > > data (length will not be standard every time). But when I run, it gets stuck
    > > - any suggestions?
    > >
    > > Thanks
    > >
    > > ActiveCell.Rows("1:1").EntireRow.Select
    > > Selection.Insert Shift:=xlDown
    > > ActiveCell.Select
    > > ActiveCell.FormulaR1C1 = "#"
    > > ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
    > > Selection.Insert Shift:=xlDown
    > > ActiveCell.Offset(-1, 1).Range("A1").Select
    > > Selection.Cut
    > > ActiveCell.Offset(1, -1).Range("A1").Select
    > > ActiveSheet.Paste
    > > ActiveCell.Offset(1, 0).Range("A1").Select
    > > Do Until ActiveCell.Value = ""
    > > Loop
    > >
    > >
    > >
    > > End Sub
    > >


+ 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