Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Step -1 method

Hi all, Just for knowledge that what kind of work "Step - 1" method
do and when it is used. Pleae can any friend can explain briefly as i
wasn't able to find much information about this method.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Step -1 method

Step is optional numeric expression which denotes the amount by which counter
is incremented each time through the loop.

For intTemp = 10 to 1 Step-1
Next

will have intTemp values in the order 10,9,8,7,6,...

and Step -2 will have 10,8,6,4,2



If this post helps click Yes
---------------
Jacob Skaria


"K" wrote:

Hi all, Just for knowledge that what kind of work "Step - 1" method
do and when it is used. Pleae can any friend can explain briefly as i
wasn't able to find much information about this method.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Step -1 method

It's very useful when you want to process a range of rows from the bottom to the
top or a range of columns from the right to the left.

Dim iRow as long
with activesheet
for irow = 20 to 10 step -1
if .cells(irow,"A").value = "" then
.rows(irow).delete
end if
next irow
end with

or

Dim iCol as long
dim FirstCol as long
Dim LastCol as long
with activesheet
firstcol = 1
lastcol = .cells(1,.columns.count).end(xltoleft).column

for icol = lastcol to firstcol step -1
if .cells(1,icol).value = "" then
.columns(icol).delete
end if
next icol
end with

Or just when you want to loop through any old array in reverse order.

dim ictr as long
dim myArr as variant
myarr = array("something", "else","would", "go here")
for ictr = ubound(myArr) to lbound(myarr) step -1
msgbox myarr(ictr)
next ictr

Or loop through a string
dim iCtr as long
dim myStr as string

mystr = "Just for knowledge"
for ictr = len(mystr) to 1 step -1
msgbox mid(mystr, ictr, 1)
next ictr



K wrote:

Hi all, Just for knowledge that what kind of work "Step - 1" method
do and when it is used. Pleae can any friend can explain briefly as i
wasn't able to find much information about this method.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Step -1 method

The below link would help

http://msdn.microsoft.com/en-us/library/5z06z1kb.aspx

If this post helps click Yes
---------------
Jacob Skaria


"K" wrote:

Hi all, Just for knowledge that what kind of work "Step - 1" method
do and when it is used. Pleae can any friend can explain briefly as i
wasn't able to find much information about this method.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Step -1 method

On Apr 20, 1:11*pm, Jacob Skaria
wrote:
The below link would help

http://msdn.microsoft.com/en-us/library/5z06z1kb.aspx

If this post helps click Yes
---------------
Jacob Skaria



"K" wrote:
Hi all, *Just for knowledge that what kind of work "Step - 1" method
do and when it is used. Pleae can any friend can explain briefly as i
wasn't able to find much information about this method.- Hide quoted text -


- Show quoted text -


thanks guys its very helpful
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
Creating a Drop Down List with Step by Step Instructions for 2007 remarkable Excel Worksheet Functions 2 March 22nd 09 04:36 AM
Need step by step to add invoice numbering to excel template rmt New Users to Excel 4 July 6th 08 11:45 PM
Excel 2000 Step By Step. What URL to use in Lesson 8? dougcsdp New Users to Excel 4 March 4th 08 05:07 AM
What is the step-by-step procedure for making a data list? Bobgolfs56 Excel Discussion (Misc queries) 1 April 23rd 05 02:19 PM
I need step by step instructions to create a macro for 10 imbedde. diana Excel Worksheet Functions 3 January 31st 05 01:56 AM


All times are GMT +1. The time now is 02:33 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"