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.
Frans_TruyensAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KimputerCommented:
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.
0
Frans_TruyensAuthor Commented:
I am going to try it.
0
KimputerCommented:
sorry, error resolved (control format, i.e. it's still commandbutton or textbox in the other sheets)

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
        MsgBox sh.FormControlType
        
         T = sh.Top
         L = sh.Left
         
         For Each Sheet In ActiveWorkbook.Sheets
            If Sheet.Name <> "Sheet1" Then
                 sh.Copy
                    Sheet.Select
                        ActiveSheet.Paste
                sh.Select
                Selection.Top = T
                Selection.Left = L
         
            End If
         Next
     End If

     Sheets("Sheet1").Select
     Next
 End Sub
 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Frans_TruyensAuthor Commented:
Thanks, this solves my problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.