View Single Post
  #8   Report Post  
Harlan Grove
 
Posts: n/a
Default

WLMPilot wrote...
I have created a spreadsheet that duplicates my paystub. With this
spreadsheet, I track various data fields, ie average net pay, average gross
pay, etc. All dollar fields are formatted to "Accounting". I am trying to
do a MIN/MAX on various fields. Unfortunately, if I simply type
MIN(B37:AA37), all 26 payperiods, then the result is "$ - ", which is
the display for a zero value in an "account" formatted field. . . .


So you're using zeros rather than "" for pay periods not yet entered?
Bad design. If you used "" to represent unentered values instead, you
could use MIN as-is since it ignores cells not evaluating to numbers.

. . . I am trying to
create a moving cell reference so that the MIN function will not pick up the
unused payperiods (columns). Below is the formula that I thought would work,
but it keeps saying there is an error and I don't know what the error is:

=MIN(B37:ADDRESS(37,COUNTIF(B37:AA37,"0")+1,4) )

....

This doesn't work because ADDRESS returns a text string, not a range
reference. That is, the ADDRESS call would return something like "V37",
not V37. That would reduce your formula to

=MIN(B37:"V37")

and that's a syntax error. If you enclose the ADDRESS call in an
INDIRECT call, the "V37" effectively becomes V37, a range reference. So
if

=MIN(B37:INDIRECT(ADDRESS(37,COUNTIF(B37:AA37,"0" )+1,4)))

returns an error, it'd be due to the COUNTIF call returning something
invalid.

Alternatives: if you want to exclude pay periods in which the values
are zero, use the *ARRAY* formula

=MIN(IF(B37:AA370,B37:AA37))

[Enter array formulas using the [Ctrl]+[Shift]+[Enter] key
combination.] Or use a variation on your original formula

=MIN(OFFSET(B37,0,0,COUNTIF(B37:AA37,"0"),1))

or get tricky

=LARGE(B37:AA37,COUNTIF(B37:AA37,"0"))