LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Looping through a range

Hi,

I'm pretty new at learning Excel vba and I'm trying to loop through some
cell values to find the largest total. For example, if cells A1:C3 contain
the following values:

1,2,3
4,6,8
5,9,7

I'm trying to find the largest total of two cells but excluding cells in
the same row (ie A1+A2, A1+A3, A1+B2, A1+B3, B1+A2, B1+A3 etc). So far
I've got the following loops:

Range("A1").Select
For i = 0 To 2
* * For j = 1 To 2
* * * * * * tempValue = ActiveCell.Value
* * * * * * tempValue2 = ActiveCell.Offset(j, i).Value
* * * * * * tempTotal = tempValue + tempValue2
* * * * * * If tempTotal total Then total = tempTotal
* * Next j
Next i

These seem to do what I need for working down and across from cell A1 but
I'm not sure how to extend this to include combinations like B1+A2, B1+B2 &
B1+C2. Am I missing something really obvious as to how to go about this or
can someone point me in the right direction?

Thanks

Shawn
 
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
Looping thru a range of cells COBOL Dinosaur New Users to Excel 9 June 2nd 07 03:41 AM
Looping through range names Craig Excel Programming 4 September 16th 05 05:20 AM
looping across columns in range? Amy Excel Discussion (Misc queries) 3 July 19th 05 08:01 PM
help with looping range and extracting value Pb21 Excel Programming 3 October 19th 04 03:58 AM
looping through a range Jo[_6_] Excel Programming 1 October 21st 03 11:11 PM


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

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

About Us

"It's about Microsoft Excel"