View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Missing something? does not count correctly

for starters:

2 Cells:
? range("G11,CX298").Address
$G$11,$CX$298

27648 cells:
? range("G11","CX298").Address
$G$11:$CX$298

but it seems improbable that you want to either loop over that entire range
or even just the two cells.

It seems like you would want to walk down a single column, then for each row
in the column, work with the cells in that row.

is the pattern 8 IND's and either brk or lunch, for a total of 9 cells?

Dim cell as Range, cell1 as Range
Dim bLunchDue as boolean, bHadLunch as boolean

for each cell in Range("G11:G298")
bLunchDue = False
bHadLunch = False
' now walk across the row or reference cells in the row.
for each cell1 in cell.Resize(1,96-7)
if application.Countif(Cell1.Resize(1,8),"IND") = 8 then
if bLunchDue then
cell1.offset(0,8).Value = "lun"
bLunchdue = False
bHadLunch = True
else
cell1.offset(0,8).Value = "brk"
if not bHadLunch then bLunchDue = True
end if
end if
Next
Next

--
Regards,
Tom Ogilvy


"hotherps " wrote in message
...
Can someone tell me what is wrong with this?
I guess I'm going about it the wrong way. I have a row (96 cells) that
will only be partially populated. Where evere it starts I need to begin
counting from that cell. Then based on the cells that have the value
"IND" in them insert the values below.

Thanks

c = 0
for each cell. range("G11,CX298")
if cell.value < "" then
c = c + 1
If cell.value = "IND" _
and c = 8 then
cell.offset(0,9).value = "Brk"

If cell.value = "IND" _
and c = 16 then
cell.offset.value(0,16) = "Lun"
cell.offset.value(0,17) = "Lun"

If cell.value = "IND" _
and c = 24 then
cell.Offset(0,25)value = "Brk"

If cell.value = "IND" _
and c = 32 then
cell.Offset(0,32)value = "Brk"

if cell.value = "" then
c = 0
end if (5 times)
next


---
Message posted from http://www.ExcelForum.com/