Rename Textbox on Worksheets
Are they textboxes from the Drawing toolbar? Or are they from the Control
toolbox toolbar?
If from the Forms toolbar:
Option Explicit
Sub testme01()
Dim TB As TextBox
Dim wks As Worksheet
Dim iCtr As Long
For Each wks In ActiveWorkbook.Worksheets
iCtr = 1
For Each TB In wks.TextBoxes
TB.Name = "TB" & iCtr
iCtr = iCtr + 1
Next TB
Next wks
End Sub
If from the Control toolbox toolbar:
Option Explicit
Sub testme02()
Dim OLEObj As OLEObject
Dim wks As Worksheet
Dim iCtr As Long
For Each wks In ActiveWorkbook.Worksheets
iCtr = 1
For Each OLEObj In wks.OLEObjects
If TypeOf OLEObj.Object Is MSForms.TextBox Then
OLEObj.Name = "TB" & iCtr
iCtr = iCtr + 1
End If
Next OLEObj
Next wks
End Sub
Darren Hill wrote:
I have several worksheets each of which have 4 identical textboxes.
I'd like to rename each of the textboxes (say, TB1, TB2, TB3, TB4) so I
can create code for all the sheets and not have to work with the unique
names each box has at present.
How do I do this, or is there a better way to access the textboxes (say,
by their underlying cell refs)?
Thanks in advance.
--
Darren
--
Dave Peterson
|