Hello,
I have a sheet that is basically a map. I have a drop down that now unhides a shape with its matching name. The shapes are lines showing path from one cell to another.
One of the cells contains the name of a shape.
When I click the Cell I'd like the corresponding shape to unhide. and others of same type to hide.
The shape names either start with a T or an R.
When i click a T shape hide all other T shapes and show the one that name its matches the value of the selected cell.
This is the code that reads the drop down value.
This is how I hide the shapes that start with "T"
This code updates values in a cell based on clicked items.
I have an attempt at code to capture the active cell value to pass to the shape unhide step: not working and commented out.
Any advice is greatly appreciated.
Thank you,
Mark
I have a sheet that is basically a map. I have a drop down that now unhides a shape with its matching name. The shapes are lines showing path from one cell to another.
One of the cells contains the name of a shape.
When I click the Cell I'd like the corresponding shape to unhide. and others of same type to hide.
The shape names either start with a T or an R.
When i click a T shape hide all other T shapes and show the one that name its matches the value of the selected cell.
This is the code that reads the drop down value.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim tShow As Variant
Dim rShow As Variant
Dim tbl As Worksheet
Dim cMp As Worksheet
Set tbl = Worksheets("Tables")
Set cMp = Worksheets("Campus")
' unhide shape for tank path
If Target.Address = "$AC$5" Then
Call HideTanks
tShow = tbl.Range(CStr("$M$2")).Value
cMp.Shapes.Range(CStr(tShow)).Visible = True
End If
' unhide reactor shape path
If Target.Address = "$AJ$5" Then
Call HideReactors
rShow = tbl.Range(CStr("$K$2")).Value
cMp.Shapes.Range(CStr(rShow)).Visible = True
End If
End Sub
This is how I hide the shapes that start with "T"
VBA Code:
Sub HideTanks()
Dim tbl As Worksheet
Dim cMp As Worksheet
Dim sHp As Shape
Dim tNk As Variant
Dim i As Variant
Set tbl = Worksheets("Tables")
Set cMp = Worksheets("Campus")
tNk = tbl.Range("J2:J" & tbl.Range("J" & Rows.Count).End(xlUp).Row)
With cMp
For Each i In tNk
cMp.Shapes.Range(CStr(i)).Visible = False
Next i
End With
End Sub
This code updates values in a cell based on clicked items.
I have an attempt at code to capture the active cell value to pass to the shape unhide step: not working and commented out.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim tbl As Worksheet
Dim cMp As Worksheet
Dim vShow As Variant
Set tbl = Worksheets("Tables")
Set cMp = Worksheets("Campus")
' press clear button cell
If Selection.Count = 1 Then
' Clear All
If Not Intersect(Target, Range("$AC$2")) Is Nothing Then
Call HideEachShape
' Clear Tanks
ElseIf Not Intersect(Target, Range("$AF$2")) Is Nothing Then
Call HideTanks
' Clear Reactors
ElseIf Not Intersect(Target, Range("$AK$2")) Is Nothing Then
Call HideReactors
End If
On Error GoTo ws_exit
Application.EnableEvents = False
'If Target.Address = "$AC$5" Then
' Call HideTanks
'vShow = cMp.Range(CStr(ActiveCell)).Value
'cMp.Shapes.Range(CStr(vShow)).Visible = True
' End If
' check for click in column AQ Tank equipment items
If Target.Column = 43 And _
Target.Row > 7 Then
If Target.Value <> "" Then
Range("AC8").Value = ActiveCell.Value ' rewrite in AC8 what ever is clicked - named cell aLoc
End If
End If
' Check for click in column AS Reactor equipment items
If Target.Column = 45 And _
Target.Row > 7 Then
If Target.Value <> "" Then
Range("AJ8").Value = ActiveCell.Value ' rewrite in cell AK8 what ever is clicked - named cell bLoc
End If
End If
End If
ws_exit: Application.EnableEvents = True
End Sub
Any advice is greatly appreciated.
Thank you,
Mark