Help With Specific selection

LurnExcel

New Member
Joined
Jan 25, 2010
Messages
18
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
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,207,277
Messages
6,077,488
Members
446,286
Latest member
ropebender

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