TypeMismatch, run time error 13...

albertc30

Well-known Member
Joined
May 7, 2012
Messages
1,091
Office Version
  1. 2019
Platform
  1. Windows
Hi all, again.

If I can't do the simple thing, I will NEVER ever stand a chance at learning how to correctly code.

Ok. There's a form that loads when a spreadsheet is clicked;

Code:
Private Sub Worksheet_Activate()

    CustForm.Show


End Sub

This form has 4 command buttons.

One of these buttons are called New Customer (form name "adnecustomer", button name is "CBCusNewCus") and it should open the new customer form.
Now this was working fine, till I done something but I don't have a clue on earth what did I do.

Code:
Private Sub CBCusNewCus_Click()
    
    CustForm.Hide
    adnecustomer.Show
    
End Sub

What on earth have I done to make the entire thing go crazy?

All other two forms that were working fine have completely gone bonkers.

Even though I have been meddling with vba excel coding for a few years now, I am pretty much a novice. This takes me through the night as I do love it and how it works. Sadly, I'll never amount to a brilliant coder I'm afraid.

Again, any help is well and truly welcome and much appreciated.

Please point out in the right direction.

Regards,
Carlos
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
try reversing these:

Code:
Private Sub CBCusNewCus_Click()
    
    CustForm.Hide
    adnecustomer.Show
    
End Sub


Code:
Private Sub CBCusNewCus_Click()

    adnecustomer.Show   
    CustForm.Hide

    
End Sub
 
Upvote 0
Still won't have it.

Still returns error

run time error 13

type mismatch

and points out to adnecustomer.Show.

This was working fine.

What on earth did I do?

Thanks for helping.

Cheers.
 
Upvote 0
Just a shot in the dark but I would try
Code:
Private Sub CBCusNewCus_Click()
    Stop
    CustForm.Hide
    adnecustomer.Show
End Sub
and after clicking the button and the code stops, use the F8 key to advance the execution of the code one line at a time and see if by chance it's something beyond this where the error occurs.
 
Upvote 0
HI mate.

There was nothing wrong with my code that I have shared above.

The issue, after hours of thinking was that I made the mistake of duplicating the form and then changed a few field names. Once I got to those and corrected them across the code forms are now loading and working.

Another thing I just learned was that the "load form" does not actually show the form, instead it loads it into the memory. So having to use form.show rather than load form.

Much appreciated for your help, as always.

Cheers.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top