Code for moving textbox

  • Thread starter Thread starter Phil Perry
  • Start date Start date
P

Phil Perry

I want to use a macro to shift a text box from one
position to another on the sheet. I was given the
following code:
Sheet1.TextBox1.Top=Sheet1.Range("B2").Top
Sheet1.TextBox1.Left=Sheet1.Range("B2").Left
When I execute the macro I get the message
METHOD OR DATA MEMBER NOT FOUND

Can someone advise what I am doing wrong here
Your help will be appreciated.
Thank you
 
The only case where I get this error message is where TextBox1 doesn't exist
on Sheet1 in the workbook where the macro finds a Sheet1. Since most every
workbook has a Sheet1, I suggest you be more explicit about which Sheet1 you
mean by specifying the workbook. Here is one way:

Sub moveit()
With Workbooks("Book1.xls").Worksheets("Sheet1")
.TextBox1.Top = Sheet1.Range("B2").Top
.TextBox1.Left = Sheet1.Range("B2").Left
End With
End Sub

Bob Kilmer
 
Back
Top