Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default loopig in Macro Programming

In ordinary programming language like Basic we have a command called "loop"
which is used for recurring a command or a series of commands to reach a
criteria. How should it be done in Macro?
Specifically I want to cut and paste specified cells and then do it again
for another cells.
Any help is highly appreciated.
TIA, Rasoul


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default loopig in Macro Programming

All MS Office programming is in the Visual Basic for Applications
language, which should give you an idea of how it ties in with Basic.
;-)

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
In ordinary programming language like Basic we have a command called "loop"
which is used for recurring a command or a series of commands to reach a
criteria. How should it be done in Macro?
Specifically I want to cut and paste specified cells and then do it again
for another cells.
Any help is highly appreciated.
TIA, Rasoul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default loopig in Macro Programming

Rasoul,

You have a number of options

a For loop which uses a counter, such as

For i = 1 To 10
Cells(i,"A").Value = i
Next i

a For Each loop which uses an o bject, such as

i=1
For Each cell In Range ("A1:A10")
cell.Value = i
i = i + 1
Next cell

or a Do Loop

i = 1
Do
Cells(i,"A").Value = i
i = i + 1
Loop Until i 10

Obviously the boundary criteria will change depending upon your requirement,
as will the actions.

There is also a While statement, but I don't use it but you may want to look
up in Help.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Rasoul Khoshravan Azar" wrote in message
...
In ordinary programming language like Basic we have a command called

"loop"
which is used for recurring a command or a series of commands to reach a
criteria. How should it be done in Macro?
Specifically I want to cut and paste specified cells and then do it again
for another cells.
Any help is highly appreciated.
TIA, Rasoul




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default loopig in Macro Programming

From vba HELP index asking for LOOP
Do...Loop Statement
Repeats a block of statements while a condition is True or until a condition
becomes True.
Syntax

Do [{While | Until} condition]
[statements]
[Exit Do]
[statements]

Loop

Or, you can use this syntax:

Do
[statements]
[Exit Do]
[statements]

Loop [{While | Until} condition]

The Do Loop statement syntax has these parts:

Part Description
condition Optional. Numeric expression or string expression that is
True or False. If condition is Null, condition is treated as False.
statements One or more statements that are repeated while, or until,
condition is True.


--
Don Guillett
SalesAid Software

"Rasoul Khoshravan Azar" wrote in message
...
In ordinary programming language like Basic we have a command called

"loop"
which is used for recurring a command or a series of commands to reach a
criteria. How should it be done in Macro?
Specifically I want to cut and paste specified cells and then do it again
for another cells.
Any help is highly appreciated.
TIA, Rasoul




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default loopig in Macro Programming

Rasoul,

There are a variety of loop structures available in VBA. For
example: For/Next, For Each/Next, Do While, and Do Until. See
on line help for more details or post back with a more specific
question.


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




"Rasoul Khoshravan Azar" wrote in
message ...
In ordinary programming language like Basic we have a command

called "loop"
which is used for recurring a command or a series of commands

to reach a
criteria. How should it be done in Macro?
Specifically I want to cut and paste specified cells and then

do it again
for another cells.
Any help is highly appreciated.
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
Macro / Programming to lock cells Neil Holden Excel Discussion (Misc queries) 1 August 5th 09 01:21 PM
Macro Programming Question mtbcpa Excel Discussion (Misc queries) 2 November 26th 07 04:51 PM
Programming (macro) breaks due to translation RBeau Excel Discussion (Misc queries) 6 June 6th 06 09:41 PM
macro programming problem Dave Murto[_2_] Excel Programming 1 January 3rd 04 02:29 AM
Macro Programming Jamie[_3_] Excel Programming 1 August 27th 03 08:20 PM


All times are GMT +1. The time now is 05:07 PM.

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"