What do you want to happen when you select more than one cell (like that whole
row)?
If you want the sub to not do anything, then start your code like:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if target.cells.count > 1 then exit sub
''''your code''''
If you want to show the calendar for the first cell in the intersection of
(columns B or G) and the selection:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B1,g1").EntireColumn) Is Nothing Then
Set Target = Intersect(Target, Range("b1,g1").EntireColumn)(1)
With Calendar1
.Value = Target
.Top = Target.Offset(0, 1).Top
.Left = Target.Offset(0, 1).Left
.Visible = True
End With
Else
Calendar1.Visible = False
End If
End Sub
ps. I moved the .visible to the bottom of the with/end with portion. Move it,
then make it visible was less distracting than showing, then moving (well, for
me anyway).
And another way to write this:
Intersect(Target, Range("B1,g1").EntireColumn)
is
Intersect(Target, Range("B:b,g:g"))
(just another one of my likes <bg>.)
Or did you really mean B through G?
Intersect(Target, Range("B1:g1").EntireColumn)