title: VBA Type Mismatch (13)
body: <p>I have two option buttons on a user form (SecurityRadio and SafteyRadio). When I click on Security radio, I want to apply a filter to a sheet name "Security" and then assign that new range to a variable name. For SwitchesRadio, I want the same procedure to happen but with a different sheet.</p>
  
  <p>However, when I select the SwitchesRadio and click on the Go button my code errors when I try to assign the new range to a listbox on a different user form. The error is Run-Time error 13,"Type mismatch" on .ListBox2.. near the end (see comment). Any idea how I can fix this?  </p>
  
  <pre><code>Private Sub GoButton_Click()
  Dim Security As Worksheet, Switches As Worksheet, CurrentSheet As Worksheet
  Dim LastAddressCurrent1 As Range, LastRowCurrent1 As Long, LastColCurrent1 As Long
  Dim LastAddressCurrent2 As Range, LastRowCurrent2 As Long, LastColCurrent2 As Long
  Dim RA_Range As Range, Comp_Range As Range
  
  If SwitchesRadio Then
      Set CurrentSheet = Sheets("Switches")
  ElseIf SecurityRadio Then
      Set CurrentSheet = Sheets("Security")
  Else
      MsgBox "Please select a product type to continue"
  End If
  
  'retrieve the last cell row number and column
  With CurrentSheet
      Set LastAddressCurrent1 = .Cells(.Rows.Count, "A").End(xlUp)
      LastRowCurrent1 = LastAddressCurrent1.Row
      LastColCurrent1 = Cells(1, Columns.Count).End(xlToLeft).Column
  End With
  
  CurrentSheet.Range(Cells(2, 1), Cells(LastRowCurrent1, LastColCurrent1)).AutoFilter Field:=2, Criteria1:="RA"
      With CurrentSheet
      Set LastAddressCurrent2 = .Cells(.Rows.Count, "A").End(xlUp)
      LastRowCurrent2 = LastAddressCurrent2.Row
      LastColCurrent2 = Cells(1, Columns.Count).End(xlToLeft).Column
      End With
  Set RA_Range = CurrentSheet.Range(Cells(2, 1), Cells(LastRowCurrent2, LastColCurrent2))
  CurrentSheet.ShowAllData
  CurrentSheet.Range(Cells(2, 1), Cells(LastRowCurrent1, LastColCurrent1)).AutoFilter Field:=2, Criteria1:="Comp"
      With CurrentSheet
      Set LastAddressCurrent2 = Cells(.Rows.Count, "A").End(xlUp)
      LastRowCurrent2 = LastAddressCurrent2.Row
      LastColCurrent2 = Cells(1, Columns.Count).End(xlToLeft).Column
      End With
  Set Comp_Range = CurrentSheet.Range(Cells(2, 1), Cells(LastRowCurrent2, LastColCurrent2))
  CurrentSheet.ShowAllData
  
  'Assign names to appropriate list boxes
  With MainSelectionForm
  .ListBox2.RowSource = RA_Range ****** errors here 
  .ListBox1.RowSource = Comp_Range
  
  End With
  End Sub
  </code></pre>