I have an Excel userform wherein the user selects a member number from a combo box, a state from a second combo box and one or multiple counties from a list box. I then have a "Calculate" button that I want to sum the number of members in the selected state and countiesr. There can be just one state but multiple counties selected. I'm more of an expert in Access in which I'd use the DSUM function in VBA. In Excel, I'm guessing I will need to use the SumIfS function along with the wrapping SUM function.
My problem is creating the string for the county criteria. I've tried using the SPLIT function to create an array from the string but that doesn't work. When I manually enter a county name such as "Pima" into the function, it works but when I try to manufacture the string with VBA it doesn't work. Here's the formula I'm using:
Me!txtMembers = Application.WorksheetFunction.Sum(Application.WorksheetFunction.SumIfs(Range("Members"), Range("ST"), Me.Controls("cboState").Value, Range("County"), strCounties))
When the user presses the "Calculate" button a string is created by looping through the county list box. I need to put something in Criteria2 automatically but I can't seem to find the secret sauce. Access is much easier but, in this case, I need to use Excel because of its better pivot tables.
My problem is creating the string for the county criteria. I've tried using the SPLIT function to create an array from the string but that doesn't work. When I manually enter a county name such as "Pima" into the function, it works but when I try to manufacture the string with VBA it doesn't work. Here's the formula I'm using:
Me!txtMembers = Application.WorksheetFunction.Sum(Application.WorksheetFunction.SumIfs(Range("Members"), Range("ST"), Me.Controls("cboState").Value, Range("County"), strCounties))
When the user presses the "Calculate" button a string is created by looping through the county list box. I need to put something in Criteria2 automatically but I can't seem to find the secret sauce. Access is much easier but, in this case, I need to use Excel because of its better pivot tables.