View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default what wrong here, range Cell as counter

I'm not sure I understand, but...

Dim myRng as range
dim myCell as range
dim mySubRngCol as range
dim mySubRngRow as range

with worksheets("Somesheet")
set myrng = .range("a1:CV100")
end with

'for columns
for each mysubrngcol in myrng.columns
for each mycell in mysubrngcol.cells
msgbox mycell.address
next mycell
next mysubrngcol

'or for rows...
for each mysubrngrow in myrng.rows
for each mycell in mysubrngrow.cells
msgbox mycell.address
next mycell
next mysubrngrow

=========
You could also use something like:

dim myCell2 as range
dim myCell as range
dim myrng as range

'same kind of assignments

for each mycell in myrng.cells
for each mycell2 in intersect(mycell.entirecolumn, myrng).cells
msgbox mycell2.address
next mycell2
next mycell

And use mycell.entirerow to do the rows.

John wrote:

Dave Peterson wrote:
This is the confusing question. I want cell to reer to a particular cell
range in MyRange. Using the I want Subrange(Cell) to fer to another range.

For instance say Myrange=Cells((1,1),Cells(100,100))

Mycell=cells(10,10) within that range
Mcol(Mycel)= the range of cells in the column Mycel is part of within
Myrange. Myrow(MyCell) is the range of cells in the row that Mycell is
part of.

Doing a for next I have set subrange(Mycell)=union(SubRow(mycount),
SubCol(mycount). This is the column and row coming out of Cell Mycell
for every Cell in Myrange.

Now... when I hit Mycell I want to count, say, all the 1's in the column
and row of Mycell. I do it by countif using subrange(MyCell) except it
doesn't work. I can't use subrange(mycount) because I don't know what
mycount is at this point.

The actual subranges are much more complicated than jut row and
column... this is just for example.

It just seems excel used Mycell as a range sometime and as a value
sometimes and that isn't controllable.

John

So my question is what did you mean by this:
Subrange(cell)


--

Dave Peterson