Consulting

Results 1 to 11 of 11

Thread: Indirect & Networkdays Functions - Tab Reference

  1. #1
    VBAX Regular
    Joined
    Apr 2017
    Posts
    66
    Location

    Indirect & Networkdays Functions - Tab Reference

    Trying use Networkdays along with the Indirect function to pick up a range of holidays on the "HolidayTab" of a workbook. There are 10 different ranges of holidays in this tab and the range selected will depend on the value in column A in TabA.

    Note, I am working in "TabB"

    I have this function working if I reference the holiday ranges in a separate workbook (Holidays.xls) as below.

    Working:
    =NETWORKDAYS(TabA!E17,TabA!F17,INDIRECT("Holidays.xls!" &TabA!A17))
    But I want to have the holiday ranges in a separate tab in the same workbook as TabA and cannot get this to work. Have tried variations on formula below but not working.


    Not Working
    =NETWORKDAYS(TabA!E17,TabA!F17,INDIRECT("HolidayTab!" &TabA!A17))
    Can someone help with the syntax?

  2. #2
    VBAX Regular
    Joined
    Apr 2017
    Posts
    66
    Location
    Maybe this is a setting issue or even a bug ..... I have working in a similar spreadsheet using a tab reference and even working with no reference to the tab holding holidays at all. But cant get working is the subject spreadsheet.

    Would like to know the issue, not very familiar with Indirect.

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Works fine for me.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Apr 2017
    Posts
    66
    Location
    Thanks for looking at this and encouraging working for you. I still can't get to work. Created a new file to test and getting #Ref! > Invalid Cell Reference error. I included some screen shots below - hoping may help ID the problem.
    Last edited by BrI; 07-01-2017 at 09:20 AM.

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Please post a workbook, rather than screenshots.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    VBAX Regular
    Joined
    Apr 2017
    Posts
    66
    Location
    Thanks,

    Attached is a sample workbook. Dates etc are in TabA, formula is in TabB, and Holidays are in Holidays2017 tab.

    Getting # Ref error.
    Attached Files Attached Files

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Create a range name BC for Holidays2017!B2:B16 and use =NETWORKDAYS(TabA!B3,TabA!C3,INDIRECT(TabA!$A3))
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Alternatively, set up your holiday dates as a table and use
    =NETWORKDAYS(TabA!B3,TabA!C3,INDIRECT("Table1[@" & TabA!$A3 & "]"))
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #9
    VBAX Regular
    Joined
    Apr 2017
    Posts
    66
    Location
    Fantastic! that works - much appreciated, spent hours on this.

    Also, as soon as I named the range the existing formula (below) started working.

    =NETWORKDAYS(TabA!B3,TabA!C3,INDIRECT("Holidays2017!" &TabA!$A3))

  10. #10
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    For clarification, the alternative solution does not require you to create named ranges.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  11. #11
    VBAX Regular
    Joined
    Apr 2017
    Posts
    66
    Location
    Thanks, that may explain why some of my other "holiday" workbooks were functioning as I had been occasionally using tables but never named a range for these.

Posting Permissions

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