+ Reply to Thread
Results 1 to 9 of 9

Call up Macro's Not working

  1. #1
    Registered User
    Join Date
    03-02-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Call up Macro's Not working

    Hi there,

    Currently have two codes I'm trying to get to work together

    HTML Code: 
    And

    HTML Code: 
    And trying to get them to run together using

    HTML Code: 
    But upon opening the file it doesnt work and I receive the Compile Error, having had a look around the fix seems to be to rename the module, but even renaming them something really random doesnt seem to work and keeps throwing this error up,

    Does anyone have any solutions?

    Thanks!
    Last edited by Lew_SJH; 03-04-2011 at 07:28 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Call up Macro's Not working

    You can only have one set of workbook event code in a workbook at a time. You need to combine all your workbook open events into one etc.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    03-02-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Call up Macro's Not working

    Thanks Dom,

    this is my first attempt at VBA so im not the greatest, how do i go about combining it all?

    I've tried inserting both formulas into "thisworkbook" but keep getting the ambiguous compile error message?

    Thanks

    Lewis
    Last edited by romperstomper; 03-04-2011 at 08:57 AM. Reason: remove unnecessary quote

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Call up Macro's Not working

    Quite an ambitious first attempt

    As an example you've got your two workbook open events:

    Please Login or Register  to view this content.

    Which should be combined to:

    Please Login or Register  to view this content.

    You would need to do the same with your BeforeClose event codes depending on the order you wish the code to execute.

    As to the location of your code all workbook/worksheet event codes should go on the relevant ThisWorkbook or Sheet code pages. Pretty much everything else should go in a regular module. Some info here that explains it.

    Dom

  5. #5
    Registered User
    Join Date
    03-02-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Call up Macro's Not working

    Quote Originally Posted by Domski View Post
    Quite an ambitious first attempt

    As an example you've got your two workbook open events:

    Please Login or Register  to view this content.

    Which should be combined to:

    Please Login or Register  to view this content.

    You would need to do the same with your BeforeClose event codes depending on the order you wish the code to execute.

    As to the location of your code all workbook/worksheet event codes should go on the relevant ThisWorkbook or Sheet code pages. Pretty much everything else should go in a regular module. Some info here that explains it.

    Dom

    Brilliant thanks for that, will give it a go now, thanks for the help (so far I've got it working exactly how I want it to but Macro's are having to be enabled at all times which isnt the best) so will be good to get the force macro working aswell

    One other question, My director (the one who asked me to try and make this work) will need access to all the sheets, is there a simple way of re-jigging the "case" structure to allow more than one sSName?

    I've seen the example PASSWORDFORM4 file but think I would struggle adapting that code to my code giving this is my first attempt!

    Thanks again Dom

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Call up Macro's Not working

    Sorry, which code are you trying to change to reflect that?

    Dom

  7. #7
    Registered User
    Join Date
    03-02-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Call up Macro's Not working

    Sorry its in the User Form Section

    HTML Code: 
    As you can see I have everyone set up to view their own respective sheets and the main "sales board" sheet, but the user named Rod is required to view all of the sheets, if that makes sense?

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Call up Macro's Not working

    One method you might want to consider is using the user's logon ID to unhide the sheets rather than a name or password.

    If you name the worksheets with the user's logon ID's a simple sub like this would do the trick:

    Please Login or Register  to view this content.

    For your existing code you could just set a case for your boss and call your ShowAllSheets macro.

    Dom

  9. #9
    Registered User
    Join Date
    03-02-2011
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Call up Macro's Not working

    thanks!

    will test and report back

+ 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