ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code for moving textbox (https://www.excelbanter.com/excel-programming/271164-code-moving-textbox.html)

Phil Perry

Code for moving textbox
 
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

Bob Kilmer

Code for moving textbox
 
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

"Phil Perry" wrote in message
...
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




Tom Ogilvy

Code for moving textbox
 
The code worked fine for me.

Regards,
Tom Ogilvy

"Phil Perry" wrote in message
...
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





All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com