Runtime Error 13: Type Mismatch

Solved
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

  • Votes
  • Date
  • Descending date
  1. Contributor
    Hello,
    does the error occur when you only change cell C7?

    does the error occur when you change just one cell?
    1. No, the error occurs anywhere on the sheet.
    2. Contributor
      @BelinosI didn't understand "move a cell on my sheet": how do you do that?
    3. @yg_beWell, I select the frame of a cell and move it to another location.
    4. Contributor
      @BelinosAh ok, you copy the content of a cell to neighboring cells!