Question: I am trying to perform a CountIfs function where two criteria are met. First a line is "Approved" and second the Appv Date is within the reporting month. The CountIfs works find when only the first criteria exists but when I add the second I get a Type Mismatch error and I am not sure why. 

Code:

```
' Declarations
Dim sRoutine As String 'Routine’s Name
Dim lngStatus As Long
Dim lngLastRow As Long
Dim intRptMnth  As Integer
Dim intRptYr    As Integer
Dim lngAppvDate  As Long

' Initialize Variables
lngLastRow = FindLastRow(strPSR_File, strCCL, 1)
lngStatus = Worksheets(strCCL).Range(FindLoc(strPSR_File, strCCL,"status")).Column
lngAppvDate = Worksheets(strCCL).Range(FindLoc(strPSR_File, strCCL,"Approved Date")).Column

intRptMnth = CInt(CalcRptMnthNum)
intRptYr = CalcRptYr

' Procedure
With Worksheets(strCCL)
CalcPCR_MTD_Cnt = Application.WorksheetFunction.CountIfs( _
    Worksheets(strCCL).Range(Cells(2, lngStatus), Cells(lngLastRow, 
    lngStatus)), _
    "=Approved", _
'********ERRORS HERE*****
    Month(Worksheets(strCCL).Range("n2:n3")), _
    intRptMnth)
'************************
End With

```

Answer: 
You can grab the selected item using `lb2.SelectedItem` and split it as you are doing, then take the rest of the items (filtering out the item with an index of `lb2.SelectedIndex` by using a `Where` clause) and then do a `SelectMany` on the results, splitting each on a space character:

```
var nonSelected = lb2.Items.OfType<string>()
    .Where((item, index) => index != lb2.SelectedIndex);

var first = lb2.SelectedItem.ToString().Split(' ');
var rest = nonSelected.SelectMany(others => others.Split(' ')).ToArray();

```
* Verify that there's at least one selected item, to avoid exceptions.
* Insert in the first array the content of the currently selected ListBox item, splitting it using [String.Split()](https://learn.microsoft.com/en-us/dotnet/api/system.string.split?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.String.Split);k(TargetFrameworkMoniker-.NETFramework&view=netframework-4.7.2) (since we're splitting on a white space, no need to specify a separator: it's the default).
* Take all the non-selected Items ([`.Where`](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.where?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.Linq.Enumerable.Where%60%601);k(TargetFrameworkMoniker-.NETFramework&view=netframework-4.7.2) the Item index is not the current) and use [`SelectMany`](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.selectmany?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.Linq.Enumerable.SelectMany%60%602);k(TargetFrameworkMoniker-.NETFramework&view=netframework-4.7.2) to flatten the arrays generated by splitting the content of each Item.

---

```
int currentIndex = listBox1.SelectedIndex;
if (currentIndex < 0) return;

string[] firstArray = listBox1.GetItemText(listBox1.Items[currentIndex]).Split();

string[] secondArray = listBox1.Items.OfType<string>().Where((item, idx) => idx != currentIndex)
                               .SelectMany(item => item.Split()).ToArray();

```