Quantcast
Channel: Programmers Heaven Forums RSS Feed
Viewing all articles
Browse latest Browse all 2703

Excel VBA - Dynamically Adding a Page to a Multi-Page UserForm

$
0
0
I have a multi-page userform. Currently, it’s three pages. I need to create a field where the user can input a number and it will do the following:

1. Duplicate page 3 of the Multi-Page UserForm that many times.
2. Duplicate the excel worksheet that same number of times.

I have found the following code that works for part of Step 2. But, I still need to work out having it repeat as many times as requested by the user.

Sub CopyWorksheet()
    Sheets("Candidate (1)").Select
    Sheets("Candidate").Copy After:=Sheets(Sheets.Count)
    Sheets("Values").Select
    Sheets("Values").Move After:=Sheets(Sheets.Count)
End Sub


I have found online the following code should duplicate a page, but it’s not working.

    Set M = IntvwWorksheet.Pages.Add("Candidate2", "Candidate 2", 4)


Can someone please help me with this. I have nearly finished everything about this UserForm except this part and I desperately need to get it figured out.

I appreciate your help!

Viewing all articles
Browse latest Browse all 2703

Trending Articles