我在excel中创建了一个宏,通过键盘命令插入一个红色箭头。我想通过研究如何让它停止选择我编写宏时选择的单元格,但我无法弄清楚如何使它每次都插入我当前选择的旁边的箭头。它目前在我记录宏时的原始行中插入箭头。有没有解决的办法?Excel vba插入箭头宏
下面是代码:
Sub Red_Arrow_Insert()
Red_Arrow_Insert Macro
Insert Red Arrow
Keyboard Shortcut: Ctrl+Shift+A
ActiveCell.Select
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 264, 50.25, 353.25, 139.5 _
).Select
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadOpen
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
End With
With Selection.ShapeRange.Line
.Visible = msoTrue
.Weight = 1.5
End With
ActiveCell.Select
End Sub
阅读此:https://msdn.microsoft.com/en-us/library/office/ff834664.aspx – teddy2
此外,我建议阅读[如何避免使用'.Select'](https:// stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros)它是在同一个单元格中完成的,因为你的'ActiveCell'永远不会改变。 – BruceWayne
对不起,这可能会超出我的水平,我不是一个程序员。这是否意味着我的请求可以完成,因为一切都必须相对于文档的左上角进行定义? –