#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Loop Macro?

which bit do you want to loop around?

--

HTH

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


"Carmen" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop a macro Steve[_71_] Excel Programming 3 February 9th 05 04:15 PM
macro loop Helen Excel Discussion (Misc queries) 7 January 12th 05 02:42 PM
macro loop stockers Excel Programming 1 October 6th 04 03:07 PM
Do...Loop Macro Cass Excel Programming 2 May 14th 04 07:14 PM
Using for loop in a macro dipti.agrawal Excel Programming 2 January 16th 04 06:18 PM


All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"