ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Help With Loop (https://www.excelbanter.com/excel-worksheet-functions/10938-help-loop.html)

Dennis

Help With Loop
 
Using this macro....

Sub Finale()
Range("B2:B11").Select
Application.Run "Move2help"
Application.Run "Drop3"
Application.Run "MoveTotal7"
Application.Run "Clean"
End Sub

What I'm trying to get to work is after the Clean macro runs I want to Loop
back to the beginning and instead of Range("B2:B11").Select I want to Select
the same Row range but one column to the right, so Range("C2:C11").Select.
Then I would like it to keep looping while incrementing up one Column each
Loop but keeping the same row range (2:11). I would like the Loop to stop when
it gets to a Column where there is no Data, So if there was data in L2:L11 but
none in M2:M11 the Macro will quit when it hits M.

TIA, Dennis
===================

Nick Hodge

Denis

This should work

Sub Finale()
Dim iLastCol As Integer, x As Integer
iLastCol = Range("IV2").End(xlToLeft).Column
For x = 2 To iLastCol
Range(Cells(2, x), Cells(11, x)).Select
'your routines here
Next x
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Dennis" wrote in message
om...
Using this macro....

Sub Finale()
Range("B2:B11").Select
Application.Run "Move2help"
Application.Run "Drop3"
Application.Run "MoveTotal7"
Application.Run "Clean"
End Sub

What I'm trying to get to work is after the Clean macro runs I want to
Loop
back to the beginning and instead of Range("B2:B11").Select I want to
Select
the same Row range but one column to the right, so Range("C2:C11").Select.
Then I would like it to keep looping while incrementing up one Column each
Loop but keeping the same row range (2:11). I would like the Loop to stop
when
it gets to a Column where there is no Data, So if there was data in L2:L11
but
none in M2:M11 the Macro will quit when it hits M.

TIA, Dennis
===================




Dennis

Very nice Nick! Works great!! I wasn't even close. Thanx so much for the help.

Dennis
============


In article , "Nick Hodge"
wrote:
Denis

This should work

Sub Finale()
Dim iLastCol As Integer, x As Integer
iLastCol = Range("IV2").End(xlToLeft).Column
For x = 2 To iLastCol
Range(Cells(2, x), Cells(11, x)).Select
'your routines here
Next x
End Sub



All times are GMT +1. The time now is 08:12 PM.

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