Code for moving textbox

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
 
B

Bob Kilmer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top