ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   loop command in Macro (https://www.excelbanter.com/excel-programming/286886-loop-command-macro.html)

Rasoul Khoshravan Azar

loop command in Macro
 
In Classical programming languages like Fortran and Basic we have a command
called: "Loop or Go to" which is used to run a series of commands in
recurrence until a limit or satisfying a criteria.
In Macro I want to do some commands on cells in a raw and continue same
commands for second raw until I reach to last row. I think I am looking for
some sort of equivalent of Loop in Macro.

Could you please tell what it should be? or if the philosophy of doing such
a recurring commands differ in Macro and I am thinking in a rong way in
Macro
TIA, Rasoul




Chip Pearson

loop command in Macro
 
Rasoul,

You can certainly loop in VBA. See the VBA help for Do While, Do
Until, and For Next loops.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Rasoul Khoshravan Azar" wrote in
message ...
In Classical programming languages like Fortran and Basic we

have a command
called: "Loop or Go to" which is used to run a series of

commands in
recurrence until a limit or satisfying a criteria.
In Macro I want to do some commands on cells in a raw and

continue same
commands for second raw until I reach to last row. I think I am

looking for
some sort of equivalent of Loop in Macro.

Could you please tell what it should be? or if the philosophy

of doing such
a recurring commands differ in Macro and I am thinking in a

rong way in
Macro
TIA, Rasoul






Gord Dibben

loop command in Macro
 
Rasoul

This code will look through column D until it runs out of rows with data.
Uses Do/While

Sub findthings()
With ActiveSheet.Range("D:D")
Set c = .Find("xx", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

Gord Dibben Excel MVP

On Tue, 6 Jan 2004 00:41:50 +0330, "Rasoul Khoshravan Azar"
wrote:

In Classical programming languages like Fortran and Basic we have a command
called: "Loop or Go to" which is used to run a series of commands in
recurrence until a limit or satisfying a criteria.
In Macro I want to do some commands on cells in a raw and continue same
commands for second raw until I reach to last row. I think I am looking for
some sort of equivalent of Loop in Macro.

Could you please tell what it should be? or if the philosophy of doing such
a recurring commands differ in Macro and I am thinking in a rong way in
Macro
TIA, Rasoul




Sharqua[_2_]

loop command in Macro
 
There is also the For Each... Next loop. :)

One example would be:

For Each vnt_Variable in Range("A1:A6000")
If vnt_Variable.value = 1500 then
vnt_Variable.value = ""
End If
Next vnt_Variable

-Donna

-----Original Message-----
In Classical programming languages like Fortran and

Basic we have a command
called: "Loop or Go to" which is used to run a series of

commands in
recurrence until a limit or satisfying a criteria.
In Macro I want to do some commands on cells in a raw

and continue same
commands for second raw until I reach to last row. I

think I am looking for
some sort of equivalent of Loop in Macro.

Could you please tell what it should be? or if the

philosophy of doing such
a recurring commands differ in Macro and I am thinking

in a rong way in
Macro
TIA, Rasoul



.



All times are GMT +1. The time now is 08:34 AM.

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