I'm running a fairly simple code and getting runtime error 13 (type mismatch). I've run macros similar to this many times before and I'm not sure what's causing this.
Private Sub CommandButton21_Click()
Dim source As Range, source2 As Range, ICCP As Range, ICCP2 As Range, Devtype As Range, Devtype2 As Range, cell As Range, cell2 As Range, destination As Range, i As Long, j As Long
Set source = Sheet2.Columns(1)
Set source2 = Sheet3.Columns(1)
Set ICCP = Sheet2.Columns(2)
Set ICCP2 = Sheet3.Columns(2)
Set Devtype = Sheet2.Columns(4)
Set Devtype2 = Sheet3.Columns(4)
If TypeName(Selection) <> "Range" Then
MsgBox "Select a range first."
Exit Sub
Else
Set cell = Selection
End If
If TypeName(Selection) <> "Range" Then
MsgBox "Select a range first."
Exit Sub
Else
Set cell2 = Selection
End If
Set destination = Sheet1.Columns(1)
For Each cell In source
Select Case cell.Value
Case "BHPL", "CAISO", "CECD", "CFE", "CSU", "EPE", "FEUS", "HHWP", "IID", "PNW", "POPD", "PRPA", "PSCO", "ROSA", "ROSP", "SCE", "SDGE", "SRSG", "SWTC", "TEP", "TSGT", "VEA", "WALC"
Case Else
cell.EntireRow.Delete
End Select
Next cell
For Each cell2 In source2
Select Case cell2.Value
Case "BHPL", "CAISO", "CECD", "CFE", "CSU", "EPE", "FEUS", "HHWP", "IID", "PNW", "POPD", "PRPA", "PSCO", "ROSA", "ROSP", "SCE", "SDGE", "SRSG", "SWTC", "TEP", "TSGT", "VEA", "WALC"
Case Else
cell.EntireRow.Delete
End Select
Next cell2
End Sub
That's the updated code, debugger is catching it at this line:
Case "BHPL",...