Cell Reference issue

K

KMartin

I have a formula:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(Sheet1!N:N,ROW(Sheet1!N2:N65536)
-ROW(Sheet1!N1),0,1)),--(Sheet1!N2:N65536="Dog"))

Calculating the sheet takes forever because of the cell range.
Sometime the sheet will have 10 rows other times it will have 10,000
rows, so I put the range N2:N65536. I already have a count of the
number of rows in a cell. Can I refer to that cell in the range, for
example: N2:N&B1 (where B1 has the number of rows)?

I tried it a ton of ways but can't get it to work. Any input would be
appreciated.
:confused:
 
D

daddylonglegs

The most efficient way would probably be

N2:INDEX(N:N,B1)

You could also use

=INDIRECT("N2:N"&B1)
 
K

KMartin

Thank you...using N2:INDEX(N:N,B1) definitely has me on the right track


I am getting a #Value! error, but when I evaluate the error the cel
reference is showing the range I want
 
K

KMartin

One more question...

I think my error is because I am referencing another sheet in th
workbook. If I move my formula over to Sheet1, it seems to work fine.
I know I read something about getting the error if you reference
closed workbook, but both sheets are in the same workbook. Do I nee
to refer to Sheet1 or Sheet2 differently?

=SUMPRODUCT(SUBTOTAL(3,OFFSET(Sheet1!N:N,ROW(Sheet1!N2:INDEX($N:$N,Sheet2B1))-ROW(Sheet1!N1),0,1)),--(Sheet1!N2:INDEX($N:$N,Sheet2!B1)="High")
 
D

daddylonglegs

If the formula isn't in sheet1 then I think you need "sheet1!" before
the $N:$N, i.e.

=SUMPRODUCT(SUBTOTAL(3,OFFSET(Sheet1!N:N,ROW(Sheet1!N2:INDEX(Sheet1!$N:$N,Sheet2!B1))-ROW(Sheet1!N1),0,1)),--(Sheet1!N2:INDEX(Sheet1!$N:$N,Sheet2!B1)="High"))
 
D

daddylonglegs

Glad it worked for you.

Just out of interest, I can't quite see what the SUBTOTAL/OFFSET par
of the formula is giving you, can you explain what it's supposed t
count
 
H

Harlan Grove

daddylonglegs wrote...
If the formula isn't in sheet1 then I think you need "sheet1!" before
the $N:$N, i.e.

=SUMPRODUCT(SUBTOTAL(3,OFFSET(Sheet1!N:N,ROW(Sheet1!N2:INDEX(Sheet1!$N:$N,
Sheet2!B1))-ROW(Sheet1!N1),0,1)),--(Sheet1!N2:INDEX(Sheet1!$N:$N,Sheet2!B1)="High"))

This particular formula is equivalent to

=COUNTIF(Sheet1!N:N,"High")

which is nonvolatile. It's highly likely this COUNTIF formula would be
even more efficient.
 
D

daddylonglegs

Harlan said:
This particular formula is equivalent to

=COUNTIF(Sheet1!N:N,"High")

Harlan,

thanks

that's what I was thinking, hence my query above. I just didn't quite
trust my analysis, thought I might have missed something....
 
K

KMartin

I am allowing users to filter results and then they can recalculate the
other sheets based on the filter. The formula I used seemed to work
the best for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top