Link to home
Start Free TrialLog in
Avatar of Frans_Truyens
Frans_TruyensFlag for Belgium

asked on

Copy textboxes on excel sheet to another sheet at the same position

I have a workbook with multiple sheets. On the first sheet, there are many textboxes and commandbuttons. These controls should be copied to the other sheets on exactly the same position. Please help.
Avatar of Kimputer
Kimputer

Sub Move_controls()
 Dim sh As Shape
 Dim T, L As Integer

 Sheets("Sheet1").Select
     For Each sh In ActiveSheet.Shapes
     If sh.Type <> msoComment Then
         T = sh.Top
         L = sh.Left
         
         For Each Sheet In ActiveWorkbook.Sheets
            If Sheet.Name <> "Sheet1" Then
                 sh.Copy
                    Sheet.Select
                        ActiveSheet.PasteSpecial Link:=False, DisplayAsIcon:=False
                sh.Select
                Selection.Top = T
                Selection.Left = L
         
            End If
         Next
     End If

     Sheets("Sheet1").Select
     Next
 End Sub

Open in new window


Requires sheet1 to be named "Sheet1" (if not, change the code, in the obvious 2 spots)
The results on the other sheets looks the same, but is not 100% the same (it's more of a picture than a real control). So if you still need to edit the labels, command name, etc, this solution is not for you.
If no editing is needed, it could be useful.
Avatar of Frans_Truyens

ASKER

I am going to try it.
ASKER CERTIFIED SOLUTION
Avatar of Kimputer
Kimputer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, this solves my problem.