Cell value in Code; not working

countryfan_nt

Well-known Member
Joined
May 19, 2004
Messages
758
Hello friends, hope all is well!

Please help me fix the below code; this line has an error:
Sheet2.Shapes("& Sheets("Report").Range("D4").Value&"")" & .Visible = True

Thank you very much in advance

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("D4")) Is Nothing Then

Select Case Sheets("Report").Range("D4").Value

Case Sheets("Report").Range("D4").Value
Sheet2.Shapes("& Sheets("Report").Range("D4").Value&"")" & .Visible = True

End Select

End If
End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
That line should look like this:

Code:
Sheet2.Shapes(CStr(Sheets("Report").Range("D4").Value)).Visible = True
 
Upvote 0
great, thank you! a new problem if you don't mind. I am getting the error: Run Time Error: The item with the specified name wasn't found.
please help me correct the code above. btw the code is supposed to look like this: Sheet2.Shapes("7").Visible = True, but instead of fixing it to 7, I chose to allow it to have more flexibility.
and yes there is a shape called 7.

thanks again!
 
Upvote 0
Either the shape name is wrong, or the value in D4 is not actually 7 - perhaps it has leading or trailing spaces?
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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