PC Review


Reply
Thread Tools Rate Thread

calling cells in for-loops

 
 
Derrick
Guest
Posts: n/a
 
      31st Jul 2009
whats the code that will allow me to select the row that the for loop is
currently on.. eg, if the loop starts at 1 goes to 5, and is currently
working on row 2,
i want to be using cell (column, 2) in my calcs..
thanks

 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      31st Jul 2009
For lngRow = 1 to 5
Msgbox Cells(lngRow,1)
Msgbox Range("A" & lngRow)
Next


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


"Derrick" wrote:

> whats the code that will allow me to select the row that the for loop is
> currently on.. eg, if the loop starts at 1 goes to 5, and is currently
> working on row 2,
> i want to be using cell (column, 2) in my calcs..
> thanks
>

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      31st Jul 2009
The answer depends on how your running your loop

It could be

activecell.offset(,n) where n is the offset required from the current column

or maybe

c.offset(,n)

If you post your code it will be easier to answer

Mike

"Derrick" wrote:

> whats the code that will allow me to select the row that the for loop is
> currently on.. eg, if the loop starts at 1 goes to 5, and is currently
> working on row 2,
> i want to be using cell (column, 2) in my calcs..
> thanks
>

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      31st Jul 2009
First off, the property call you want is Cells (note the 's' at the end) and
you have the arguments reversed (row first, then column). Assuming your use
of column is a stand-in for the actual column number or quoted letter, you
would use your loop counter for the currently being processed row number.
For example, if your loop counter were RowNumber, then your loop would be
set up like this...

For RowNumber = 1 To 5
.....
ValueInColumnBofCell = Cells(RowNumber, "B").Value
.....
Next

Now, of course, there are other considerations as well. For example, if you
are referencing something other than the active worksheet, there would be
references to that in the statement; but, in general, the above should get
you started.

--
Rick (MVP - Excel)


"Derrick" <(E-Mail Removed)> wrote in message
news:1A03585E-F1E4-40A0-8613-(E-Mail Removed)...
> whats the code that will allow me to select the row that the for loop is
> currently on.. eg, if the loop starts at 1 goes to 5, and is currently
> working on row 2,
> i want to be using cell (column, 2) in my calcs..
> thanks
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CALLING A RANGE OF CELLS FROM EXTERNAL SOURCE =?Utf-8?B?QU5HRUxJQ0E=?= Microsoft Excel Misc 2 3rd Aug 2006 07:35 PM
Calling on cells with red fonts celestar Microsoft Excel Discussion 1 3rd Aug 2006 12:28 PM
calling up cells from a table. tanner Microsoft Excel Worksheet Functions 5 17th May 2006 01:27 PM
SpinButton control loops infinitly when calling a ATL COM server chrislpowell@hotmail.com Microsoft Excel Programming 0 16th Mar 2005 05:43 PM
calling cells from other sheets and listing louis2112 Microsoft Excel Programming 3 19th Apr 2004 04:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:13 PM.