+ Reply to Thread
Results 1 to 5 of 5

VBA to define alias for workbook location to be used in formula

  1. #1
    Registered User
    Join Date
    09-13-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    49

    VBA to define alias for workbook location to be used in formula

    Hi folks,

    The hospital I work for provides an excel workbook for each employee in which they have to keep track of their working hours, sick-leave, holidays etc (called a jaarkaart in Dutch).
    I'm trying to make a separate excel workbook in which an automatically updated overview will be made of the data each of the people in our department fills in in his/her jaarkaart.
    Each day is represented in the jaarkaart by a block of 4 cells, the top two of which are used to fill in the working hours (am and pm) and the bottom two are used for codes to indicate illness, days off etc (see attached example).

    Currently, my overview spreadsheet is filled with formulas such as this:
    Please Login or Register  to view this content.
    Four of these per day for each employee.....
    So you can probably imagine that even for our small group of 12 people, when I try, for example, to update 2016 to 2017 by find-replace all....excel crashes because that's too much work.

    Therefore, I was wondering if it is possible to define aliasses for the locations of the jaarkaarten in VBA and use those aliasses in the formulas, so that the formulas will end up looking something like this:
    Please Login or Register  to view this content.
    I tried making a private sub which basically contained the following for each employee:
    Please Login or Register  to view this content.
    But that didn't work.

    Hope you can help me out.
    Thanks in advance.
    Thirsa
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA to define alias for workbook location to be used in formula

    Given the way you've currently set up your system I'd be inclined in your summary workbook to link all four cells for each day for each month for each person directly to the cells in that person's workbook.

    At least that avoids any complex Indirect functions. The other way would be to have a Macro to read each workbook and copy or connect the cells to the summary.

    If it were me I think I'd be using something like Google Forms as a data entry form. All users would use the same Google Form to add the data required. This google form would then automatically update a spreadsheet, either a Google Sheets document or if you prefer an Excel workbook.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-13-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: VBA to define alias for workbook location to be used in formula

    Hi Richard,

    I agree with you that using something like google forms would be easier, but that would mean that we would be using a different system then the rest of the hospital and I don't think the human resources department of the hospital will accept that (they keep a central registration of all cards of all hospital employees, so naturally they want everybody to use the same system). So the only way to use google forms is to have our employees fill in the excel sheet for the HR-dept and the google form for our own overview. Knowing how busy everybody's schedules are, I can tell you that that won't happen.

    So indeed it might be easiest to simply create direct links instead of my crazy formulas. The reason I had those in my current version is that I was planning on using conditional formats to colour code the overview and to keep the conditions as straightforward as possible, I need all four cells of each day to contain information. And unfortunately, that is not always the case: When the info for the morning and afternoon are the same, most people only fill in the info in one set of the cells...and some use the am cells for that whereas others use the pm cells.

    But I guess that making the formatting conditions a bit more complex is less stressful for Excel than my current crazy formulas, so I think I'll take your advice and use direct links.

    Thanks

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA to define alias for workbook location to be used in formula

    Hi,

    I agree with your analysis.

    Longer term you should be trying to persuade HR to use a different layout. i.e. a single normalised 2 dimensional table where each record is added as a separate row. In your case you have columns for

    Date
    Time
    Name
    Working Hours
    Code

    That would be far more useful since when summarised into a master database HR could use Pivot Tables for analysis and obtain a lot more useful management information.

  5. #5
    Registered User
    Join Date
    09-13-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: VBA to define alias for workbook location to be used in formula

    Hi Richard,

    Unfortunately, our HR folks (or the IT folks....don't know who to blame here) can be pretty stubborn, so I doubt that I'll be able to convince them to start using a different layout.
    But....it never hurts to try....

    Thanks again for thinking along.
    Thirsa

+ 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] VBA refine code .PrintOut to define pdf Filename and current location
    By cnhtractor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2014, 06:37 PM
  2. [SOLVED] Specify export pdf file location is location workbook is saved.
    By dantray02 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2014, 01:13 PM
  3. Call a specific workbook from a file location and move worksheet to different workbook
    By dwhite30518 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2014, 01:46 AM
  4. Replies: 9
    Last Post: 06-24-2013, 04:14 PM
  5. define vba for only one workbook
    By sarelvv in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2012, 09:51 AM
  6. Export worksheets from a workbook to the current workbook location path
    By legendkiller420 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-22-2010, 04:08 AM
  7. [SOLVED] [SOLVED] delete workbook from one location and save workbook to new locatio
    By Damien in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2006, 10:40 AM

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