仅供参考,我也在Excel论坛上发布了这个帖子。
弹出此代码并在excel中添加注释的新窗口,但我在主题行中收到错误消息。当我点击调试时,它会突出显示第一个代码," Activesheet.shapes(" ScreenS")。textframe ...
我使用我在网上找到的代码并根据我的需要进行调整。但我无法弄清楚形状名称的来源:
CloseV
ScreenB
ScreenS
Header
任何帮助都将非常感谢!!
'This piece of code displays the complete article in the pop-up when the user clicks on the relevant cell
'Crab Sheet, 2012
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("C6:J15,C18:E25,G18:J25")) Is Nothing Then
ActiveSheet.Shapes("ScreenS").TextFrame.Characters.Text = ""
Dim Display_Str As String
Dim Header_Str As String
'Hiding the form controls for better display
Shapes("Spinner 7").Visible = False
Shapes("Drop Down 3").Visible = False
Shapes("Option Button 1").Visible = False
Shapes("Option Button 2").Visible = False
'UnHiding the shapes for displaying message
Shapes("CloseV").Visible = True
Shapes("ScreenB").Visible = True
Shapes("ScreenS").Visible = True
Shapes("Header").Visible = True
'Select Case to determine which of the three merged cells have been clicked
Select Case Target.Address
'Case if Company Overview is selected
Case "$C$6:$J$15"
Display_Str = [CompanyDescription].Value
Header_Str = [CompanyName].Value & " - Company Overview"
'Case if Recent News is selected
Case "$C$18:$E$25"
Display_Str = [RecentNews].Value
Header_Str = [CompanyName].Value & " - Recent News"
'Case if Pipeline Details is selected
Case "$G$18:$J$25"
Display_Str = [PipelineNews].Value
Header_Str = [CompanyName].Value & " - Key Pipeline"
Case Else
End Select
'Adding relevant text to display in the shapes
Shapes("ScreenS").TextFrame.Characters.Text = Display_Str
Shapes("Header").TextFrame.Characters.Text = Header_Str
'Protecting the sheet so that the user doesnot change the set-up of shapes
ActiveSheet.Protect Password:="1"
End If
End Sub
'
'This code closes the pop-up and returns the dashboard to its normal state
'Crab Sheet, 2012
'
Sub closeview()
'UnProtecting the sheet so that the user can make changes
ActiveSheet.Unprotect Password:="1"
'UnHiding the form controls
Shapes("Spinner 7").Visible = True
Shapes("Drop Down 3").Visible = True
Shapes("Option Button 1").Visible = True
Shapes("Option Button 2").Visible = True
'Hiding the shapes for displaying message
Shapes("CloseV").Visible = False
Shapes("ScreenB").Visible = False
Shapes("ScreenS").Visible = False
Shapes("Header").Visible = False
End Sub