+ Reply to Thread
Results 1 to 18 of 18

2 different macros to run on two different sheets in a workbook

  1. #1
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    2 different macros to run on two different sheets in a workbook

    Hi There,

    I have two macros (see attached macro1 & macro2) in two different sheets (Process Wise TAT & Dept Wise TAT) in a workbook. Also I have numerous sheets with details of process activities and their turn around time (TAT). In sheets Process Wise TAT & Dept Wise TAT i have set few formulas to fetch data from other sheets and do certain calculations to display end result.

    I want the attached macros to hyperlink sheets with details. However macro1 is working fine but macro two is throwing error (highlighted in Yellow). Please can someone help me fix this.
    Attached Images Attached Images

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: 2 different macros to run on two different sheets in a workbook

    Why post screenshots?

    You will get a better response if you post the code for each macro using code tags (#)

    Type or Paste your macro then click > go advanced

    Highlight your code and click the # button

    e.g.
    Please Login or Register  to view this content.


    Cheers
    Last edited by Marcol; 06-24-2010 at 06:48 AM.

  3. #3
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: 2 different macros to run on two different sheets in a workbook

    Thanks Marcol. Another learning as a new user.

    Here are the macros:

    macro1:
    Please Login or Register  to view this content.
    macro2:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: 2 different macros to run on two different sheets in a workbook

    I am finding it difficult to work out what you want done.

    Could you post a sample workbook to clarify things?

    It should clearly illustrate your problem and not contain any sensitive data.

  5. #5
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: 2 different macros to run on two different sheets in a workbook

    Hi,

    Please find attached workbook that contains sampe worksheets.

    What i have in work book:

    - Numerous sheets that contain details of the projects.
    - Two sheets:
    1. Process Wise TAT: this sheet contains TAT (turn around time) of the process activities that are carried out to complete a project. Data is being pulled from project sheets( 100001 - 100003) using few formulas.

    Note: Data start point destination cells are same for all sheets with project details.

    2. Dept Wise TAT: this sheet contains Time taken for complettion by each Dept (Maker & Checker) for a project. Data is being pulled from project sheets( 100001 - 100003) using few formulas.

    I am trying to get done the following:

    1. As and when a sheet (project details) is added, hyperlink should be listed automatically in Process Wise TAT and Dept Wise TAT (E.g. B4:B10000).

    2. In every sheet with project details a return link should be created. For Process Wise TAT link with text 'Back to Process Wise TAT' in E5 and for Dept Wise TAT link with text 'Back to Dept Wise TAT' in B5.

    Note: There should be any to and from hyperlinks between the Process Wise TAT and Dept Wise TAT sheets.


    Additional requirement:

    As I have set formulas in Process Wise TAT and Dept Wise TAT to fetch details from other sheets, I would like these formulas to run automatically if possible.

    I would be grateful if someone can help me with this.

    Many thanks in advance.

    Cheers,
    Az.
    Attached Files Attached Files

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

    Re: 2 different macros to run on two different sheets in a workbook

    I too can't tell what you are doing or want. The example isn't much help because you haven't even added the code. At a guess,maybe
    Please Login or Register  to view this content.
    Hope that helps.

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

    Free DataBaseForm example

  7. #7
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: 2 different macros to run on two different sheets in a workbook

    Hi Roy,

    Here's my workbook with codes. when I tried the codes I have mentioned earlier worked fine with the sample workbook and did what I wanted (hyperlinking back and forth). But when I used the same codes on the original workbook I am getting an error on th e following code for sheet 'Dept Wise TAT' but the code for sheet 'Process Wise TAT' is working fine.

    Please Login or Register  to view this content.

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

    Re: 2 different macros to run on two different sheets in a workbook

    There's no attachment & what error are you getting?

    Which sheet will have the button?
    Last edited by royUK; 06-27-2010 at 04:55 AM.

  9. #9
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: 2 different macros to run on two different sheets in a workbook

    Hi Roy,

    Would be grateful if I can get help on the second requirement as well. Just so you know, I don't know how to write codes myself but with the help of my colleague (who knows basic coding) I tweaked the code I got from the link below to meet my requirements.

    http://www.ozgrid.com/VBA/sheet-index.htm

  10. #10
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: 2 different macros to run on two different sheets in a workbook

    Oops! forgot the attachement. Sorry about that. Here it is...
    Attached Files Attached Files

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

    Re: 2 different macros to run on two different sheets in a workbook

    It seems to work for me

  12. #12
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: 2 different macros to run on two different sheets in a workbook

    what error are you getting?
    Please see ataached.

    Which sheet will have the button?
    Just to make it simpler i have removed the button codes.
    Attached Images Attached Images

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

    Re: 2 different macros to run on two different sheets in a workbook

    I can't duplicate the error in your example. Are the sheets named differently in the other workbook?

  14. #14
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: 2 different macros to run on two different sheets in a workbook

    Hi Roy,

    Looks like it got auto-corrected and it is working fine now. Thanks for all your efforts.

    Could you please help me with second requirement if possible?

    Additional requirement:

    As I have set formulas in Process Wise TAT and Dept Wise TAT to fetch details from other sheets, I would like these formulas to run automatically if possible.

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

    Re: 2 different macros to run on two different sheets in a workbook

    I don't understand your second requirement,unless Calculation is set to manual then formulas should update

  16. #16
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: 2 different macros to run on two different sheets in a workbook

    Sorry for a vague requirement description.
    In 'Process Wise TAT' sheet I have formulas (C4 to K4 and rows down) for pulling details from other project sheets. Likewise in 'Dept Wise Sheet' I have formulas from C4 to H4 and rows down.

    Whenever i add a new project sheet to the workbook, i need to write and run these formulas manually. I was just wondering if there is a way to have these formulas run automatically if a new sheet is added.

    E.g.:

    In Process Wise TAT sheet if a new project sheet is added (100004) cell C7 should pick the formula from cell C6 ('100003'!$C$3) and replace the sheet name in the formula with new sheet name ('100004'!$C$3) or any other way to auto-insert this formula.

    I have tried to put it the best way possible however if it is still confusing please let me know.

    Cheers,
    Az

  17. #17
    Registered User
    Join Date
    06-13-2010
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: 2 different macros to run on two different sheets in a workbook

    Would highly appreciate if someone can help me with this please.

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

    Re: 2 different macros to run on two different sheets in a workbook

    I suggest that you start a new thread for this other question, with a link to this one

+ 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