Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Error '13' Type Mismatch

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tanya - 25 May 2008 09:01 GMT
Hi I have a macro in my workbook which appears to be activated whenever data
changes. For example, if I delete a piece of data or paste data.

Here is the error:

Run-time error '13'
Type Mismatch
choose [End]   or  [Debug]

I have been choosing 'End' as a solution, but it is becoming annoying. Below
is a copy of my code which comes up when you choose 'Debug'. If any one could
help I would be very grateful.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
   Const BUTTON_COUNT = 10
   Const SHEET_WITH_BUTTONS = "Setup"

   Dim ButtonDefs() As Variant
   ReDim ButtonDefs(0 To BUTTON_COUNT - 1)

   ' START OF BUTTON DEFINITIONS
   'Each array is three strings:
   'Name of change sheet, change cell address, associated button name
   ButtonDefs(0) = Array("1", "B1", "CommandButton1")
   ButtonDefs(1) = Array("2", "B1", "CommandButton2")
   ButtonDefs(2) = Array("3", "B1", "CommandButton3")
   ButtonDefs(3) = Array("4", "B1", "CommandButton4")
   ButtonDefs(4) = Array("5", "B1", "CommandButton5")
   ButtonDefs(5) = Array("6", "B1", "CommandButton6")
   ButtonDefs(6) = Array("7", "B1", "CommandButton7")
   ButtonDefs(7) = Array("8", "B1", "CommandButton8")
   ButtonDefs(8) = Array("9", "B1", "CommandButton9")
   ButtonDefs(9) = Array("10", "B1", "CommandButton10")
   '
   '...CONTINUE THESE DEFINITIONS AS NEEDED...
   ' END OF BUTTON DEFINITIONS

   Dim arr As Variant
   For Each arr In ButtonDefs
       'NOTE: the following assumes Option Base 0 (the default)
       swcc = arr(0)   'sheet with change cell
       cca = arr(1)    'change cell address
       bn = arr(2)     'button name
       If StrComp(Sh.Name, swcc, vbTextCompare) = 0 Then
           If Target = Me.Worksheets(swcc).Range(cca) Then
               Me.Worksheets(SHEET_WITH_BUTTONS).OLEObjects(bn). _
                   Object.Caption = Target.Text
           End If
       End If
   Next
End Sub

Kind Regards
Tanya
Tanya - 25 May 2008 09:04 GMT
PS the line which highlights when you select DEBUG is

If Target = Me.Worksheets(swcc).Range(cca) Then

cheers
Tanya
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.