AW: Textboxnummern ändern
27.09.2013 14:57:28
fcs
Hallo Albrecht,
ich hab mal im Archiv gestöbert nach "Steuerelement umbenennen".
Hier ist zumindest mal ein Ansatz für Checkboxen.
https://www.herber.de/forum/archiv/1084to1088/1086348_CheckBoxen_mit_VBA_umbenennen.html#1086466
Gruß
Franz
Option Explicit
Sub test()
Dim objCh
Dim i As Integer, ii As Integer
Dim myAr(), myArCh
Dim temSH As Worksheet
With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
With ThisWorkbook.VBProject
For i = 1 To .VBComponents.Count
If .VBComponents(i).Name = "UserForm1" Then
Set objCh = .VBComponents(i)
Exit For
End If
Next i
End With
Redim myAr(objCh.Designer.Controls.Count - 1, 1 To 3)
For i = 0 To objCh.Designer.Controls.Count - 1
If TypeName(objCh.Designer.Controls.Item(i)) = "CheckBox" Then
objCh.Designer.Controls.Item(i).Name = "TempNameCH" & i + 1
myAr(ii, 1) = i
myAr(ii, 2) = objCh.Designer.Controls.Item(i).Left
myAr(ii, 3) = objCh.Designer.Controls.Item(i).Top
ii = ii + 1
End If
Next i
Set temSH = Worksheets.Add
With temSH
.Range("A1").Resize(Ubound(myAr, 1) + 1, Ubound(myAr, 2)) = myAr
.UsedRange.Sort .Range("B1"), xlAscending, .Range("C1"), , xlAscending, , , xlNo
myArCh = .Range("A1", .Cells(.Rows.Count, 1).End(xlUp))
.Delete
End With
ii = 1
For i = 1 To Ubound(myArCh)
objCh.Designer.Controls.Item(myArCh(i, 1)).Name = "CheckBox" & ii
ii = ii + 1
Next i
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
End With
End Sub