Run Code with having row selected

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,074
Office Version
  1. 2019
Platform
  1. Windows
I have this code that displays msgbox. However its dependent on the row selected. How can I click the red triangle to display the msgbox without having the need to have the row selected?

VBA Code:
Sub Callout()
Dim shMsg As Shape, shID
Dim cel As Range

On Error Resume Next
shID = ActiveSheet.Shapes("Callout").ID

If Not IsEmpty(shID) Then
    ActiveSheet.Shapes("Callout").Delete
ElseIf Not Range("S" & ActiveCell.Row).Comment Is Nothing Then
    Set shMsg = ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangularCallout, 112.5, 112.5, 150, 1)
    Set cel = Range("S" & ActiveCell.Row)
   
    With shMsg
        .Name = "Callout"
        .TextFrame.Characters.Text = Range("S" & ActiveCell.Row).Comment.Text
        .Left = cel.Left - .Width
        .Top = cel.Offset(1).Top
        .Adjustments.Item(1) = 0.52
        .Adjustments.Item(2) = -0.65
        .TextFrame2.AutoSize = msoAutoSizeShapeToFitText
    End With
End If
End Sub


1594928310809.png
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I don't get 2 things about this you wrote:
"How can I click the red triangle to display the msgbox without having the need to have the row selected?"

Thing 1:
What row not needing to select? The row where the red triangle is, or some other row where you want the red triangle to be located.

Thing 2:
If my "Thing 1" is totally off the target, then that would mean you want to place a red triangle on any row you feel like putting the red triangle on, which is fine, but how the code would know your desired row is the issue, probably solvable with an InputBox to ask the user to input what the destination row for this red triangle should be.

If my "Thing 1" and "Thing 2" are off the mark, then sorry, what you are asking may very well be clear to someone else, but just speaking for myself, you lost me on what you are asking for.
 
Upvote 0

Forum statistics

Threads
1,215,218
Messages
6,123,676
Members
449,116
Latest member
HypnoFant

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