I've been having problems where I make an object on a sheet and its given an automatic name...
For example I create a text box using a macro, it will be named "text box 1" I get the problem when I macro grabs text box 1 and moves it but after I've run the macro a few times text box 1 is now text box 10 or something.
How can I add a line of code that when the macro runs and creats a text box it names it something that I set that will be consistant.
So Add a line saying something like
ActiveSheet.Shapes.AddTextbox.name = "my new text box name"
As you can see form the above code the last line says .
ActiveSheet.Shapes("Text Box 1").Select
but if that macro was run twice it wouldnt be text box 1 any more...
Hope that makes sence sorry its a bit long winded!
For example I create a text box using a macro, it will be named "text box 1" I get the problem when I macro grabs text box 1 and moves it but after I've run the macro a few times text box 1 is now text box 10 or something.
How can I add a line of code that when the macro runs and creats a text box it names it something that I set that will be consistant.
Code:
ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 47.25, 100.5, _
209.25, 84.75).Select
Selection.Characters.Text = "Hello world"
With Selection.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.ShapeRange.IncrementLeft 18#
Selection.ShapeRange.IncrementTop 13.5
ActiveSheet.Shapes("Text Box 1").Select
So Add a line saying something like
ActiveSheet.Shapes.AddTextbox.name = "my new text box name"
As you can see form the above code the last line says .
ActiveSheet.Shapes("Text Box 1").Select
but if that macro was run twice it wouldnt be text box 1 any more...
Hope that makes sence sorry its a bit long winded!