Name an Object So I Can Format for User

drmingle

Board Regular
Joined
Oct 5, 2009
Messages
229
The below code works well (If I use activesheet), however there are many tabs in the workbook. If a user is on another worksheet besides the ("Pricing") sheet vba bombs on the line in red.

How can I ask the code to execute on line when I haven't even assigned a name (which is directly under the red line.

Code:
        Sheets("Pricing").Shapes.AddTextBox(msoTextOrientationHorizontal, 803.8235433071, _
        1.7647244094, 607.9411811024, 189.7058267717).Select
        [COLOR=#ff0000][B]Selection.ShapeRange.Line.Visible = msoFalse[/B][/COLOR]
        Selection.Name = "txtBox1"
        Range("F10:J10").Select

Thank you for any help.
 
I am sure there is a more elegant solution, but I decided to force the code to select the sheet before running the remaidner code.

Sheets("Pricing").Select
 
Upvote 0
Untested:

Code:
With Sheets("Pricing").Shapes.AddTextBox(msoTextOrientationHorizontal, 803.8235433071, _
        1.7647244094, 607.9411811024, 189.7058267717)
        .ShapeRange.Line.Visible = msoFalse
        .Name = "txtBox1"
End With
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top