+ Reply to Thread
Results 1 to 5 of 5

Public function to create new sheet, with optional argument

  1. #1
    Registered User
    Join Date
    08-27-2019
    Location
    Alabama, USA
    MS-Off Ver
    365, 2016, 2010, 2007
    Posts
    57

    Public function to create new sheet, with optional argument

    Hello,
    I am working on a small piece of a larger project and am having issues getting it to work.

    It is a public function with one required argument and one optional argument. It creates a new sheet named after the first REQUIRED argument, and places it at the end of all sheets if the second OPTIONAL argument is omitted, or if the second OPTIONAL argument is specified, places it after the sheet named by the second OPTIONAL argument.

    It currently works when specifying both arguments, but I cannot figure out how to make it work when the optional argument is omitted.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,996

    Re: Public function to create new sheet, with optional argument

    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    08-27-2019
    Location
    Alabama, USA
    MS-Off Ver
    365, 2016, 2010, 2007
    Posts
    57

    Re: Public function to create new sheet, with optional argument

    Thank you for your reply, and it functioned as it was, however when used without an argument it placed the new sheet where you were currently selected within the workbook instead of at the end.

    I was able to take your code and modify it to work correctly, both with the optional argument and without. I however, doubt this is the best way to achieve this, I ended up having to be rather repetitive to get it to work.

    Any suggestions are welcome.

    Please Login or Register  to view this content.
    Again, thank you protonLeah for your help thus far.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,996

    Re: Public function to create new sheet, with optional argument

    just:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-27-2019
    Location
    Alabama, USA
    MS-Off Ver
    365, 2016, 2010, 2007
    Posts
    57

    Re: Public function to create new sheet, with optional argument

    Thank you protonLeah, the function still performs as intended after that small optimization.

    I will now mark this as solved.

    Thank you for your help and time,
    Trent Spencer - KM4YTU

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Using a With Statement within a Public Function ('Argument not Optional' Error)
    By stevoDE in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-15-2017, 07:31 AM
  2. Error for VBA function - "Argument Not Optional?"
    By EverGreen1231 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2017, 01:59 PM
  3. [SOLVED] Excel VBA Function with optional argument
    By blackgericom in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-06-2016, 12:52 PM
  4. [SOLVED] Optional declared argument is not optional
    By tnuis in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-28-2015, 06:59 AM
  5. Using a Boolean function within an If statement: Argument not optional error message
    By elfsprin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2011, 04:12 PM
  6. 2nd. argument (Optional ) in COUNTA() function
    By Rabi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-13-2007, 08:30 AM
  7. optional argument in a function
    By visitor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2005, 03:06 PM

Tags for this Thread

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