Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Looping Macro

I have this looping macro that work like a gem. But it has
one glich or thing I would like to fix.

When the macro is running and it encounters a empty cell I
want it to stop running in the coloum it started in, move
to the top of the worksheet, move over 9 cells and start
agian.

Can anyone help me see the light on this.

Do
ActiveCell.Name = "Sort2"
ActiveCell.Offset(0, 6).Range("A1").Select
ActiveCell.Name = "Sort3"
Range("Sort2:Sort3").Select
Selection.Sort Key1:=Range("Sort2"),
Order1:=xlAscending, Orientation:=xlLeftToRight
Range("Sort2").Select
Application.CutCopyMode = False
ActiveWorkbook.Names("Sort2").Delete
ActiveWorkbook.Names("Sort3").Delete
ActiveCell.Offset(1, 0).Select
If Empty Then Exit Do
Loop
End Sub

The if Empty does nothing, the loop contiues to the last
row of the spread sheet.

Pete
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Looping Macro

Pete,

This is the sort of thing, but what stops the outer loop?

Do
Do
With ActiveCell
.Name = "Sort2"
.Offset(0, 6).Range("A1").Select
.Name = "Sort3"
End With
Range("Sort2:Sort3").Select
Selection.Sort Key1:=Range("Sort2"), _
Order1:=xlAscending, _
Orientation:=xlLeftToRight
Range("Sort2").Select
Application.CutCopyMode = False
ActiveWorkbook.Names("Sort2").Delete
ActiveWorkbook.Names("Sort3").Delete
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Value)
ActiveCell.Offset(-ActiveCell.Row + 1, 9).Select
Loop Until what <<<<

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pete" wrote in message
...
I have this looping macro that work like a gem. But it has
one glich or thing I would like to fix.

When the macro is running and it encounters a empty cell I
want it to stop running in the coloum it started in, move
to the top of the worksheet, move over 9 cells and start
agian.

Can anyone help me see the light on this.

Do
ActiveCell.Name = "Sort2"
ActiveCell.Offset(0, 6).Range("A1").Select
ActiveCell.Name = "Sort3"
Range("Sort2:Sort3").Select
Selection.Sort Key1:=Range("Sort2"),
Order1:=xlAscending, Orientation:=xlLeftToRight
Range("Sort2").Select
Application.CutCopyMode = False
ActiveWorkbook.Names("Sort2").Delete
ActiveWorkbook.Names("Sort3").Delete
ActiveCell.Offset(1, 0).Select
If Empty Then Exit Do
Loop
End Sub

The if Empty does nothing, the loop contiues to the last
row of the spread sheet.

Pete



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Looping Macro

I want the loop to continue until it finds an empty cell
at the top of the sheet.

Pete

-----Original Message-----
Pete,

This is the sort of thing, but what stops the outer loop?

Do
Do
With ActiveCell
.Name = "Sort2"
.Offset(0, 6).Range("A1").Select
.Name = "Sort3"
End With
Range("Sort2:Sort3").Select
Selection.Sort Key1:=Range("Sort2"), _
Order1:=xlAscending, _
Orientation:=xlLeftToRight
Range("Sort2").Select
Application.CutCopyMode = False
ActiveWorkbook.Names("Sort2").Delete
ActiveWorkbook.Names("Sort3").Delete
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Value)
ActiveCell.Offset(-ActiveCell.Row + 1, 9).Select
Loop Until what <<<<

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pete" wrote in

message
...
I have this looping macro that work like a gem. But it

has
one glich or thing I would like to fix.

When the macro is running and it encounters a empty

cell I
want it to stop running in the coloum it started in,

move
to the top of the worksheet, move over 9 cells and start
agian.

Can anyone help me see the light on this.

Do
ActiveCell.Name = "Sort2"
ActiveCell.Offset(0, 6).Range("A1").Select
ActiveCell.Name = "Sort3"
Range("Sort2:Sort3").Select
Selection.Sort Key1:=Range("Sort2"),
Order1:=xlAscending, Orientation:=xlLeftToRight
Range("Sort2").Select
Application.CutCopyMode = False
ActiveWorkbook.Names("Sort2").Delete
ActiveWorkbook.Names("Sort3").Delete
ActiveCell.Offset(1, 0).Select
If Empty Then Exit Do
Loop
End Sub

The if Empty does nothing, the loop contiues to the last
row of the spread sheet.

Pete



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Looping Macro

I would have thought there were enough clues in the code to work that one
out

Do
Do
With ActiveCell
.Name = "Sort2"
.Offset(0, 6).Range("A1").Select
.Name = "Sort3"
End With
Range("Sort2:Sort3").Select
Selection.Sort Key1:=Range("Sort2"), _
Order1:=xlAscending, _
Orientation:=xlLeftToRight
Range("Sort2").Select
Application.CutCopyMode = False
ActiveWorkbook.Names("Sort2").Delete
ActiveWorkbook.Names("Sort3").Delete
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Value)
ActiveCell.Offset(-ActiveCell.Row + 1, 9).Select
Loop Until IsEmpty(ActiveCell.Value)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pete" wrote in message
...
I want the loop to continue until it finds an empty cell
at the top of the sheet.

Pete

-----Original Message-----
Pete,

This is the sort of thing, but what stops the outer loop?

Do
Do
With ActiveCell
.Name = "Sort2"
.Offset(0, 6).Range("A1").Select
.Name = "Sort3"
End With
Range("Sort2:Sort3").Select
Selection.Sort Key1:=Range("Sort2"), _
Order1:=xlAscending, _
Orientation:=xlLeftToRight
Range("Sort2").Select
Application.CutCopyMode = False
ActiveWorkbook.Names("Sort2").Delete
ActiveWorkbook.Names("Sort3").Delete
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Value)
ActiveCell.Offset(-ActiveCell.Row + 1, 9).Select
Loop Until what <<<<

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pete" wrote in

message
...
I have this looping macro that work like a gem. But it

has
one glich or thing I would like to fix.

When the macro is running and it encounters a empty

cell I
want it to stop running in the coloum it started in,

move
to the top of the worksheet, move over 9 cells and start
agian.

Can anyone help me see the light on this.

Do
ActiveCell.Name = "Sort2"
ActiveCell.Offset(0, 6).Range("A1").Select
ActiveCell.Name = "Sort3"
Range("Sort2:Sort3").Select
Selection.Sort Key1:=Range("Sort2"),
Order1:=xlAscending, Orientation:=xlLeftToRight
Range("Sort2").Select
Application.CutCopyMode = False
ActiveWorkbook.Names("Sort2").Delete
ActiveWorkbook.Names("Sort3").Delete
ActiveCell.Offset(1, 0).Select
If Empty Then Exit Do
Loop
End Sub

The if Empty does nothing, the loop contiues to the last
row of the spread sheet.

Pete



.



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
Macro looping? klh84 Excel Worksheet Functions 3 February 26th 10 05:58 PM
Looping Macro KimC Excel Discussion (Misc queries) 1 January 11th 10 04:55 AM
Looping Macro Jase Excel Discussion (Misc queries) 5 March 12th 08 09:08 PM
Looping macro RK Excel Worksheet Functions 2 December 12th 06 11:29 PM
Looping a macro Sony Excel Discussion (Misc queries) 3 October 30th 06 11:52 AM


All times are GMT +1. The time now is 03:43 AM.

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

About Us

"It's about Microsoft Excel"