ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping Macro Doesn't Work (https://www.excelbanter.com/excel-programming/371514-looping-macro-doesnt-work.html)

Rob

Looping Macro Doesn't Work
 
Help. I can't seem to get this to work.

Sub Macro1()
Do While ActiveCell.Row < 7
Range("A" & ActiveCell.Row - 10).Select
Selection.ClearContents
Loop
End Sub

What did I do wrong?

Thanks
Rob

Rob

Looping Macro Doesn't Work
 
Nevermind I fig'd where I messed up...

Do While ActiveCell.Row < 7

Should have been

Do While ActiveCell.Row 7

"Rob" wrote:

Help. I can't seem to get this to work.

Sub Macro1()
Do While ActiveCell.Row < 7
Range("A" & ActiveCell.Row - 10).Select
Selection.ClearContents
Loop
End Sub

What did I do wrong?

Thanks
Rob


Cush

Looping Macro Doesn't Work
 
Rob,
You cannot select a cell in row 0 or any row less than 1. So the
activecell.row MUST be 10 if you want to then select a cell in the
Activecell.Row-10

Your code will still produce an error, say if you were coming from row 8.

"Rob" wrote:

Nevermind I fig'd where I messed up...

Do While ActiveCell.Row < 7

Should have been

Do While ActiveCell.Row 7

"Rob" wrote:

Help. I can't seem to get this to work.

Sub Macro1()
Do While ActiveCell.Row < 7
Range("A" & ActiveCell.Row - 10).Select
Selection.ClearContents
Loop
End Sub

What did I do wrong?

Thanks
Rob


Rob

Looping Macro Doesn't Work
 
So I found. I always confuse < . Thanks for the reply.

Rob

"cush" wrote:

Rob,
You cannot select a cell in row 0 or any row less than 1. So the
activecell.row MUST be 10 if you want to then select a cell in the
Activecell.Row-10

Your code will still produce an error, say if you were coming from row 8.

"Rob" wrote:

Nevermind I fig'd where I messed up...

Do While ActiveCell.Row < 7

Should have been

Do While ActiveCell.Row 7

"Rob" wrote:

Help. I can't seem to get this to work.

Sub Macro1()
Do While ActiveCell.Row < 7
Range("A" & ActiveCell.Row - 10).Select
Selection.ClearContents
Loop
End Sub

What did I do wrong?

Thanks
Rob



All times are GMT +1. The time now is 09:23 PM.

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