largeselection
Active Member
- Joined
- Aug 4, 2008
- Messages
- 358
Hello,
I have a user defined function which converts a zipcode into the state it comes from written as below:
what I'm wondering is if it would be possible to create a user defined function which would use this function to evaluate a sum without having to physically add another column to the data.
So if I have data that is just 2 columns
Zipcode, Population
I'd like to be able to put in a custom function like Customsum(Zipcode column, State, New York, Population column)
And have it spit out what the sum of the population column is for all zipcodes within New York.
I know I could add a third column to the data which is just "STATE" and use my original UDF to just populate it, then do a sumif, but I'm wondering if it's possible to skip that step.
I've tried with some arrays but they don't work. So for example I tried {=sum(if(state(A1:A100)="NEW YORK",B1:B100,""))} hoping that that might work, but no luck.
So the UDF format I'd be looking for is something similar to Customsum(Reference range, Custom UDF to evaluate, Value from UDF to sum, Reference range to sum)
Is this possible?
I have a user defined function which converts a zipcode into the state it comes from written as below:
Code:
Function State(number as string)
Select case number
Case is = "11111"
State = "Wyoming"
Case is = "22222"
State = "New York"
Case is = "33333"
State = "California"
etc.
what I'm wondering is if it would be possible to create a user defined function which would use this function to evaluate a sum without having to physically add another column to the data.
So if I have data that is just 2 columns
Zipcode, Population
I'd like to be able to put in a custom function like Customsum(Zipcode column, State, New York, Population column)
And have it spit out what the sum of the population column is for all zipcodes within New York.
I know I could add a third column to the data which is just "STATE" and use my original UDF to just populate it, then do a sumif, but I'm wondering if it's possible to skip that step.
I've tried with some arrays but they don't work. So for example I tried {=sum(if(state(A1:A100)="NEW YORK",B1:B100,""))} hoping that that might work, but no luck.
So the UDF format I'd be looking for is something similar to Customsum(Reference range, Custom UDF to evaluate, Value from UDF to sum, Reference range to sum)
Is this possible?