Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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



.

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
using a vlookup command in a for next loop in a macro in excel Amethyst Excel Discussion (Misc queries) 3 March 17th 07 01:30 PM
macro loop DM Excel Discussion (Misc queries) 1 January 3rd 06 10:46 PM
how can i loop a macro Remote help Excel Discussion (Misc queries) 1 July 21st 05 02:57 AM
Loop macro help. Pete[_13_] Excel Programming 4 November 15th 03 01:22 AM


All times are GMT +1. The time now is 09:46 AM.

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

About Us

"It's about Microsoft Excel"