I am using this code to show a shape next to the active cell. What I cannot seem to figure out is how to hide the shape if the selected cell is not empty in column D.
Code:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Box As Shape
Set Box = Me.Shapes("Flowchart: Alternate Process 10")
If Intersect(Target, Range("D2:D5000")) Is Nothing Then
Dim sObject As Shape
Dim bObject As Shape
For Each sObject In ActiveSheet.Shapes
sObject.Visible = False
Next
Exit Sub
End If
If Not Intersect(Target, Range("D2:D5000")) Is Nothing Then
For Each bObject In ActiveSheet.Shapes
bObject.Visible = True
Next
End If
If Selection.Left + Selection.Width _
+ Box.Width > Rows(1).Width Then
Box.Left = Selection.Left - Box.Width + 10
Else: Box.Left = Selection.Left + Selection.Width + 2
End If
If Selection.Top + Selection.Height _
+ Box.Height > Columns(1).Height Then
Box.Top = Selection.Top - Box.Height + 15
Else: Box.Top = Selection.Top + Selection.Height - 12
End If
Box.ZOrder msoBringToFront
End Sub