Runtime Error 13: Type Mismatch

Solved
Belinos Posted messages 15 Status Member -  
yg_be Posted messages 23437 Registration date   Status Contributor Last intervention   -
Hello,

As a beginner in VBA, I'm encountering a runtime error 13 at the line "If not application.intersect...".
Here is my code:
I added the initial part "Option Explicit and dim", but I still have an error every time I insert a line or move a cell on my sheet.

Option Explicit
Dim wsh As String
Dim sh As Variant

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("C7")) Is Nothing And Target <> "" Then
wsh = Target
With Worksheets(wsh)
.Visible = True
.Activate
End With
For Each sh In ThisWorkbook.Sheets
If sh.Name <> "Feuil1" And sh.Name <> "Feuil2" And sh.Name <> "Feuil3" And sh.Name <> "Feuil4" And sh.Name <> "Feuil5" And sh.Name <> "Feuil6" And sh.Name <> wsh Then
sh.Visible = xlVeryHidden
End If
Next
End If
End Sub


Thank you for your help!

Have a nice day!

4 answers

  1. yg_be Posted messages 23437 Registration date   Status Contributor Last intervention   Ambassadeur 1 588
     
    Hello,
    does the error occur when you only change cell C7?

    does the error occur when you change just one cell?
    0
    1. Belinos Posted messages 15 Status Member
       
      No, the error occurs anywhere on the sheet.
      0
      1. yg_be Posted messages 23437 Registration date   Status Contributor Last intervention   1 588 > Belinos Posted messages 15 Status Member
         
        I didn't understand "move a cell on my sheet": how do you do that?
        0
      2. Belinos Posted messages 15 Status Member > yg_be Posted messages 23437 Registration date   Status Contributor Last intervention  
         
        Well, I select the frame of a cell and move it to another location.
        0
      3. yg_be Posted messages 23437 Registration date   Status Contributor Last intervention   1 588 > Belinos Posted messages 15 Status Member
         
        Ah ok, you copy the content of a cell to neighboring cells!
        0