Q1. I have few rectangle shapes in cell "B3". and "B3" is label design area. if shape is moved outside cell "B3" then i need to show warning and move back selected shape to previous position from where it was moved. Therefore shape stay within design area and get printed properly. i tried following codes.
Above codes are not working as per my requirement. kindly check.
Q2 . Additionally, how i can adjust zoom size of sheet based on on column and row with of cell "B3" in inches in page layout mode with vba ?
Thank you
excel vba excel-vba
VBA Code:
Sub UndoShapesMoveOutside() 'if moved outside Design area
Dim shp As String, Adr As String
shp = Selection.Name
Adr = "B3"
Set Rng = Range("B3")
If ActiveSheet.Shapes(shp).Top <> Rng And ActiveSheet.Shapes(shp).Left <> Rng Then
'EnableEvents = False
'.Undo
'.EnableEvents = True
'.SendKeys ("^z")
MsgBox "Textbox is outside Design Area"
With ActiveSheet.Shapes(shp)
.Top = Range(Adr).Top
.Left = Range(Adr).Left
End With
End If
End Sub
Q2 . Additionally, how i can adjust zoom size of sheet based on on column and row with of cell "B3" in inches in page layout mode with vba ?
Thank you
excel vba excel-vba