Dear Forum,
I am trying to move a shape down one row on a worksheet. When I use the following code to do so on an external monitor that is attached to my laptop, the process works perfectly. If, however, I move the Excel workbook to my laptop's screen and try to perform the same operation, it errors out almost every time. Also, if I close the workbook, disconnect the external monitor, and re-open the workbook on my laptop, the same problem occurs.
By "erroring out", I mean that the shape is not placed down to the new row correctly, and code following the placement fails to execute. The shape appears halfway or so down to the new row, and all of the other dimensions seem to be set correctly. It's just not "down" in the right place.
Does anyone have any insight on this? I'm running Office 365 on a Windows 10 HP EliteBook laptop.
Option Explicit
Option Compare Text
Public Sub MoveMyShape(wksName As String, oShapeName As String)
Dim wb As Workbook
Dim wks As Worksheet
Dim oShape As Shape
Dim oShapeRow As Long
Dim oShapeColLong As Long
Dim nextRow As Long
Set wb = ThisWorkbook
Set wks = wb.Sheets(wksName)
Set oShape = wks.Shapes(oShapeName)
oShapeRow = oShape.TopLeftCell.Row
oShapeColLong = oShape.TopLeftCell.Column
nextRow = oShapeRow + 1
oShape.Top = wks.Cells(nextRow, oShapeColLong).Top
oShape.Left = wks.Cells(nextRow, oShapeColLong).Left
oShape.Width = wks.Cells(nextRow, oShapeColLong).Width
oShape.Height = wks.Cells(nextRow, oShapeColLong).Height
End Sub
Brian
Bookmarks