Archive of Mr Excel Message Board


Back to Errors in Excel archive index
Back to archive home

ERROR 13 - Type Mismatch

Posted by Montgomery on November 13, 2001 8:24 AM
Hi,

What I want to achieve here is that when the message box asks if I want to continue and I say no. I want the worksheet to be saved and the application to quit. I have gotten it to work for my other workbooks but I don't what is happening with this one.

If response = vbyes then
Textbox1.text=""
Textbox2.Text=""

Textbox1.Setfocus

Else
Unload Me.

Dim SelText As String
Dim i As Integer

Const PerilsCol = 19 'Perils in colum S
SelText = " ' "


With PerilsLbx
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
SelText = Right(SelText & ListBox1.List(i) & " ", Len(SelText & ListBox1.List(i) & " ") - 1)
End If
Next i

End With
'put value in next available cell in perils column
Cells(65536, PerilsCol).End(xlUp).Offset(1).Value = SelText
End If

End Sub

I substituted the unload me bit with code to save the workbook and exit excel and I get the error message and it also show the screen asking if I want to save the document, which I don't get with the other workbooks, but when I save the workbook and go reopen it the column for the listbox is empty. I even went as far as putting - If vbno then (execute code) and it still does not work. Could someone take a look at the above code and see if they could tell me what is wrong

Thanks,
Faye


Re: ERROR 13 - Type Mismatch- JUST NEED SOMEONE TO CHECK THIS CODE FOR ME

Posted by Montgomery on November 13, 2001 11:15 AM
With PerilsLbx For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) Then SelText = Right(SelText & ListBox1.List(i) & " ", Len(SelText & ListBox1.List(i) & " ") - 1) End If Next i End With 'put value in next available cell in perils column Cells(65536, PerilsCol).End(xlUp).Offset(1).Value = SelText End If

I just want someone to check my code


This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.