Thread: Type Mismatch
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rockee052[_60_] Rockee052[_60_] is offline
external usenet poster
 
Posts: 1
Default Type Mismatch

Hi

I am trying to figure out why I am getting a type mismatch run time
error 13 when running my code... I have searched the help file in vba
and I am still stumped. I have also done a google search and well, here
I am...

What I am trying to do is view each worksheet when clicked on in the
listbox. It was working then I added some more code for an options
command button and now there is some sort of conflict.
The listbox is on a userform.

I also have one additional question, When my option command button has
been clicked 4 times and up it changes the list box property to
multiselectmulti property when it should be multiselectsingle. Where
did I go wrong?

Thanks for any help or advice

Here is my code:

Option Explicit
Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdOption_Click()
If cmdOption.Caption = "Options " Then
Me.Height = 160.5
ListBox1.Height = 120.8
ListBox1.ListStyle = fmListStylePlain
cmdOption.Caption = "<< Options"
Else
Me.Height = 197.25
ListBox1.Height = 120.8
cmdOption.Caption = "Options "
ListBox1.ListStyle = fmListStyleOption
ListBox1.MultiSelect = fmMultiSelectMulti
End If
End Sub

Private Sub cmdPrint_Click()
Dim i As Integer
Application.ScreenUpdating = False
If cmdOption.Caption = "Options " Then
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
With Sheets(ListBox1.List(i))
PageSetup.BlackAndWhite = True
PrintOut
End With
End If
Next i
End If
Application.ScreenUpdating = True
Unload Me
End Sub

Private Sub ListBox1_Click()
Worksheets(ListBox1).Text.Activate ' type mismatch ?
Range("A1").Select
End Sub

Private Sub UserForm_Initialize()
Dim wks As Worksheet
For Each wks In Worksheets
Select Case wks.Name
Case "Parts List", "Sheet List", "All Parts", _
"All Part Numbers", "Enter Data", "Summary", _
"Logo", "HelpSheet"
Case Else: Me.ListBox1.AddItem wks.Name
End Select
Next
Me.Height = 160.5
End Sub


Rockee Freeman


---
Message posted from http://www.ExcelForum.com/