View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Visual Basic Error Run Time Error, Type Mismatch

You have a couple of potential problems...
This line
If Target = Range("D3") Then
is the same as
If Target.Value = Range("D3").Value Then
You probably wanted
If Target.address "$D$3" Then

Your lastcase is the only one that does a protection and even though you
have userinterface set to true there will still be some things that macros
will not be able to do.

There is nothing in there that will necessarily generate a type mismatch...
--
HTH...

Jim Thomlinson


"Meg Partridge" wrote:

Hello - I am receiving a Run-time error '13' Type mismatch for the code that
I have. After reading the help section of microsoft, I am still lost! The
code I am using is listed below. Any help would be greatly appreciated!!!!
Thanks!

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("D3") Then
Columns("E:N").Hidden = False
Select Case Target
Case Is = 1
Columns("N").Hidden = True
Case Is = 2
Columns("M:N").Hidden = True
Case Is = 3
Columns("L:N").Hidden = True
Case Is = 4
Columns("K:N").Hidden = True
Case Is = 5
Columns("J:N").Hidden = True
Case Is = 6
Columns("I:N").Hidden = True
Case Is = 7
Columns("H:N").Hidden = True
Case Is = 8
Columns("G:N").Hidden = True
Case Is = 9
Columns("F:N").Hidden = True
Case Is = 10
Columns("E:N").Hidden = True
For Each wSheet In Worksheets
wSheet.Protect Password:="Secret", _
UserInterFaceOnly:=True
Next wSheet
End Select
End If
End Sub