+ Reply to Thread
Results 1 to 5 of 5

Insert and name new sheet using UserForm

  1. #1
    Registered User
    Join Date
    12-05-2007
    Posts
    11

    Insert and name new sheet using UserForm

    Hello

    I'm using a UserForm to gather information.

    Two new sheet will be created and named using a field gathered from the UserForm. Ranges will be created using part of the name.

    I tried the following to name the new sheet yet receive a Run-time error; any suggestions? If possible, could someone explain the principle for using the ReportName as a variable as I need to use it naming ranges on the sheets.

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Something like this

    Please Login or Register  to view this content.
    You will get an error if a sheet exists with that name.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    12-05-2007
    Posts
    11
    I have to declare it as a variable! Makes sense I guess.

    So where the TextBox value if captured in "ReportName" I simply change change to "sReportName = Me.ReportName.Value"

    And if I need to append the sheet name, it would be "sReportName"&"Temp"?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If your TextBox is named ReportName then your amendments should work fine.

  5. #5
    Registered User
    Join Date
    12-05-2007
    Posts
    11
    Thanks royUK.

    I tried your suggested code and received a run-time error; 1004 object undefined. VBA doesn't seem to like "ActiveSheet.Name = sReportName" - any suggestions?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1