ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using loop for selection macro (https://www.excelbanter.com/excel-programming/321868-using-loop-selection-macro.html)

akoobra[_2_]

Using loop for selection macro
 
Hi all

I am having trouble automatically stopping this macro. I can run it
and then end but would prefer to have it stop automatically.

Do
ActiveCell.Columns("A:A").EntireColumn.Select
Selection.Find(what:="TL", After:=ActiveCell, LookIn:=xlValues,
LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
ActiveCell.Range("A1:U1").Select
Selection.Cut
ActiveCell.Offset(-1, 10).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.ClearContents
Selection.Delete Shift:=xlUp
Loop


End Sub

Any help would be appreciated.

Richard


No Name

Using loop for selection macro
 
you don't have a way to stop it.
do then loop.
you need to put in do until.....something.
or loop until or while....something.
when something happens the code will exit the loop.

-----Original Message-----
Hi all

I am having trouble automatically stopping this macro. I

can run it
and then end but would prefer to have it stop

automatically.

Do
ActiveCell.Columns("A:A").EntireColumn.Select
Selection.Find(what:="TL", After:=ActiveCell,

LookIn:=xlValues,
LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
ActiveCell.Range("A1:U1").Select
Selection.Cut
ActiveCell.Offset(-1, 10).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.ClearContents
Selection.Delete Shift:=xlUp
Loop


End Sub

Any help would be appreciated.

Richard

.



All times are GMT +1. The time now is 01:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com