I'm trying to allow the user to select a cell within a range and if they select any other cell they get a message. I have included the code below... If i sustitute "A3" for the Range("A3:A500") it will work. When I add the range part I get a "type mismatch" error on any cells clicked.
Any help is greatly appreciated!!!!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address(0, 0) <> Range("A3:A500") Then
MsgBox "sorry"
Else
If Intersect(Target, Range("A3:A500")) Then
If Left(ActiveCell.Offset(0, 1), 4) = "4 in" And Right(ActiveCell.Offset(0, 2), 4) <> "65 m" Or Left(ActiveCell.Offset(0, 1), 4) = "5 in" And Right(ActiveCell.Offset(0, 2), 4) <> "65 m" Then
With ActiveCell
FmIJ664Inch.LBSize = .Offset(0, 1)
FmIJ664Inch.LBSizeM = .Offset(0, 2)
FmIJ664Inch.LBSurface = .Offset(0, 3)
FmIJ664Inch.LBPC = .Offset(0, 5)
FmIJ664Inch.LBBC = .Offset(0, 6)
FmIJ664Inch.LBPrinter = .Offset(0, 7)
FmIJ664Inch.Show
End With
Else
If Left(ActiveCell.Offset(0, 1), 4) = "4 in" And Right(ActiveCell.Offset(0, 2), 4) = "65 m" Or Left(ActiveCell.Offset(0, 1), 4) = "5 in" And Right(ActiveCell.Offset(0, 2), 4) = "65 m" Then
With ActiveCell
FmIJ66M65.LBSize = .Offset(0, 1)
FmIJ66M65.LBSizeM = .Offset(0, 2)
FmIJ66M65.LBSurface = .Offset(0, 3)
FmIJ66M65.LBPC = .Offset(0, 5)
FmIJ66M65.LBBC = .Offset(0, 6)
FmIJ66M65.LBPrinter = .Offset(0, 7)
FmIJ66M65.Show
End With
Else
With ActiveCell
FmIJ66.LBSize = .Offset(0, 1)
FmIJ66.LBSizeM = .Offset(0, 2)
FmIJ66.LBSurface = .Offset(0, 3)
FmIJ66.LBPC = .Offset(0, 5)
FmIJ66.LBBC = .Offset(0, 6)
FmIJ66.LBPrinter = .Offset(0, 7)
FmIJ66.Show
End With
End If
End If
End If
End If
End Sub
Any help is greatly appreciated!!!!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address(0, 0) <> Range("A3:A500") Then
MsgBox "sorry"
Else
If Intersect(Target, Range("A3:A500")) Then
If Left(ActiveCell.Offset(0, 1), 4) = "4 in" And Right(ActiveCell.Offset(0, 2), 4) <> "65 m" Or Left(ActiveCell.Offset(0, 1), 4) = "5 in" And Right(ActiveCell.Offset(0, 2), 4) <> "65 m" Then
With ActiveCell
FmIJ664Inch.LBSize = .Offset(0, 1)
FmIJ664Inch.LBSizeM = .Offset(0, 2)
FmIJ664Inch.LBSurface = .Offset(0, 3)
FmIJ664Inch.LBPC = .Offset(0, 5)
FmIJ664Inch.LBBC = .Offset(0, 6)
FmIJ664Inch.LBPrinter = .Offset(0, 7)
FmIJ664Inch.Show
End With
Else
If Left(ActiveCell.Offset(0, 1), 4) = "4 in" And Right(ActiveCell.Offset(0, 2), 4) = "65 m" Or Left(ActiveCell.Offset(0, 1), 4) = "5 in" And Right(ActiveCell.Offset(0, 2), 4) = "65 m" Then
With ActiveCell
FmIJ66M65.LBSize = .Offset(0, 1)
FmIJ66M65.LBSizeM = .Offset(0, 2)
FmIJ66M65.LBSurface = .Offset(0, 3)
FmIJ66M65.LBPC = .Offset(0, 5)
FmIJ66M65.LBBC = .Offset(0, 6)
FmIJ66M65.LBPrinter = .Offset(0, 7)
FmIJ66M65.Show
End With
Else
With ActiveCell
FmIJ66.LBSize = .Offset(0, 1)
FmIJ66.LBSizeM = .Offset(0, 2)
FmIJ66.LBSurface = .Offset(0, 3)
FmIJ66.LBPC = .Offset(0, 5)
FmIJ66.LBBC = .Offset(0, 6)
FmIJ66.LBPrinter = .Offset(0, 7)
FmIJ66.Show
End With
End If
End If
End If
End If
End Sub