View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
GS[_5_] GS[_5_] is offline
external usenet poster
 
Posts: 226
Default Looping through Non contiguous cells in a row

avi laid this down on his screen :
Hello,

I want to loop accross each cell in a row oa a non contiguous range,
something like

for I=1 to NumberOfRows
for J=1 to NumberOfCols
msgbox MyRange.Rows(I).cells(I,J).value
next
next

The problem is that the J seems to refer to the contiguous range
starting with first column of the range

Any help
Avi


I'm thinking a problem exists with the value held in 'NumberOfCols'.
Are you using 'UsedRange.Columns.Count'? Or some other method to
determine the last column used. I would use a method similar to finding
the last row containing data. Something using 'End' and xlToLeft to
determine NumberOfCols.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc