ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Generic n in For n To xxxxx (https://www.excelbanter.com/excel-programming/352947-generic-n-n-xxxxx.html)

knowtrump[_14_]

Generic n in For n To xxxxx
 

Using For n = 1 To xxxxx step 1 or for n = xxxxx To 1 Step -1 is it
possible to state the high number in some generic foremat so that the
high number does not have to be precisely stated for each new data list
and you can be sure that the procedure has executed through the entire
data list?


--
knowtrump
------------------------------------------------------------------------
knowtrump's Profile: http://www.excelforum.com/member.php...o&userid=19664
View this thread: http://www.excelforum.com/showthread...hreadid=510873


Chip Pearson

Generic n in For n To xxxxx
 
I'm not sure what you're asking, but I'll take a guess. If you
are looping through row numbers, you can get the last used row in
column "A" with code like

xxxxx = Cells(Rows.Count,"A").End(xlUp).Row

You might want to provide a few more details.

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



"knowtrump"
wrote in
message
...

Using For n = 1 To xxxxx step 1 or for n = xxxxx To 1 Step -1
is it
possible to state the high number in some generic foremat so
that the
high number does not have to be precisely stated for each new
data list
and you can be sure that the procedure has executed through the
entire
data list?


--
knowtrump
------------------------------------------------------------------------
knowtrump's Profile:
http://www.excelforum.com/member.php...o&userid=19664
View this thread:
http://www.excelforum.com/showthread...hreadid=510873




NickHK

Generic n in For n To xxxxx
 
knowtrump,
I guess you asking:
Dim StartCounter As Long
Dim StopCounter As Long
Dim Stepper As Long
StartCounter =MyRange1.Value
StopCounter =MyRange2.Value 'Or from Karl:
=Cells(Rows.Count,"A").End(xlUp).Row
Stepper=MyRange3.Value
For i=StartCounter to StopCounter Step Stepper
......

NickHK

"knowtrump" wrote
in message ...

Using For n = 1 To xxxxx step 1 or for n = xxxxx To 1 Step -1 is it
possible to state the high number in some generic foremat so that the
high number does not have to be precisely stated for each new data list
and you can be sure that the procedure has executed through the entire
data list?


--
knowtrump
------------------------------------------------------------------------
knowtrump's Profile:

http://www.excelforum.com/member.php...o&userid=19664
View this thread: http://www.excelforum.com/showthread...hreadid=510873




knowtrump[_15_]

Generic n in For n To xxxxx
 

Thanks Chip and Nick. Sorry that my query lacked in detail. However
your answers are what I was looking for. While conventional wisdo
says there are no "dumb" questions I guess it is certainly possible t
be less than smart about how you phrase them. My bad. Thanks again

--
knowtrum
-----------------------------------------------------------------------
knowtrump's Profile: http://www.excelforum.com/member.php...fo&userid=1966
View this thread: http://www.excelforum.com/showthread.php?threadid=51087


knowtrump[_16_]

Generic n in For n To xxxxx
 

Thanks Chip and Nick. Sorry that my query lacked in detail. However,
your answers are what I was looking for. While conventional wisdom
says there are no "dumb" questions I guess it is certainly possible to
be less than smart about how you phrase them. My bad. Thanks again.


--
knowtrump
------------------------------------------------------------------------
knowtrump's Profile: http://www.excelforum.com/member.php...o&userid=19664
View this thread: http://www.excelforum.com/showthread...hreadid=510873



All times are GMT +1. The time now is 05:53 AM.

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