+ Reply to Thread
Results 1 to 7 of 7

VBA code: A Sub() module to CALL another Sub ()

  1. #1
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Post VBA code: A Sub() module to CALL another Sub ()

    Hello experts!

    I need some expert advice here please....

    I have a SaveAsPDF module created that when run, it needs to convert the worksheet into excel. But before doing that, I need another module to run first, that is to check whether certain required fields are filled or not before it converts to .pdf. Pasted are my codes for both modules. I tried calling the Checkcells module but I keep on receiving "Compile error: Argument not optional" message. Or is there a way to incorporate my codes in one module that does both functions?

    Please have time to assist. Thanks a lot in advance!

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Thanks again in advance!

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: VBA code: A Sub() module to CALL another Sub ()

    What happens if you put your PDF code at the end of the emptycell code to make it one macro?

  3. #3
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code: A Sub() module to CALL another Sub ()

    Quote Originally Posted by jolivanes View Post
    What happens if you put your PDF code at the end of the emptycell code to make it one macro?
    Hi jolivanes

    Tried your suggestion but it still shows same error: "Compile error: Argument not optional"

  4. #4
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code: A Sub() module to CALL another Sub ()

    Quote Originally Posted by hydz1213 View Post
    Hi jolivanes

    Tried your suggestion but it still shows same error: "Compile error: Argument not optional"
    CORRECTION TO ME! I tried it again....paste my PDF code under the EMPTYCELL code and it did run which is really good.
    However, when I emptied some of the specified cells (C4,E7) it still converts the worksheet into .pdf

    I was hoping to have a code that the macro will check first if there are empty cells among specified cells. If yes, it will just highlight empty cells and remind user to fill-in the form first and PDF will not run. But if all specified cells are filled-out, then macro will convert worksheet into .pdf....

  5. #5
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: VBA code: A Sub() module to CALL another Sub ()

    I think you should change the call to CheckCells from the SaveAsPDF routine

    currently you have

    Please Login or Register  to view this content.
    replace the highlighted part by

    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

  6. #6
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code: A Sub() module to CALL another Sub ()

    [QUOTE=OllieB;3115871]I think you should change the call to CheckCells from the SaveAsPDF routine

    AWESOME!!! It worked Thank you so much for your help! I wonder how can I tag this as SOLVED???

    But super thanks to your help OllieB

  7. #7
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA code: A Sub() module to CALL another Sub ()

    Quote Originally Posted by jolivanes View Post
    What happens if you put your PDF code at the end of the emptycell code to make it one macro?
    Thanks also to you jolivanes

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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