Consulting

Results 1 to 6 of 6

Thread: Cell reference in worksheet formula???

  1. #1
    VBAX Newbie
    Joined
    Jun 2004
    Posts
    5
    Location

    Question Cell reference in worksheet formula???

    I've had help from this forum before (thank you) and now I would like a little more if poss....

    Basically I have about 120 cells in a spreadsheet which reference 120 equivalent cells from a different workbook. It's a timesheet spreadsheet that 'pulls in' the data from individuals spreadsheets where they record their overtime etc etc.

    Anyway, every cell has the filename in the formula...

    ...like this....

    =IF('[Name-Jan.xls]MONTHLY TIME SHEET'!$G$16>0,('[Name-Jan.xls]MONTHLY TIME SHEET'!$G$16),"")
    This code either pulls in the value or records a blank. Works OK.

    I would rather the filename was 'referred to' rather than embedded in the formula. That would mean I could change the filename in question by modifying ONE CELL rather than messing about with all the various cells that use it.

    I will run some code to do all these changes BUT I can't work out what syntax to use.

    It 'should' look something like this (obviously doesn't work)

    =IF('[$a$1]MONTHLY TIME SHEET'!$G$16>0,('[$a$1]MONTHLY TIME SHEET'!$G$16),"")

    In this case the name of the file is stored (and easily modified) from Cell $A$1

    Has anyone got any ideas ??

    Many thanks in advance to all the helpful people out there. Still amazes me that there are so many people who will take time out to help a stranger....
    ...anyway, enough advance grovelling for now.

    Oh yes, I'm using Excel 2000 on a Windows 2000 PC

    Cheers

    Paul

  2. #2
    BoardCoder
    Licensed Coder
    VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    622
    Location
    You could make use of Indirect which allows you to pass a string as a cell refernce:


    =IF(indirect("'["&a$1&"]MONTHLY TIME SHEET'!$G$16")>0,indirect("'["&a$1&"]MONTHLY TIME SHEET'!$G$16")>,"")

    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net

  3. #3
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Yeah, Indirect is the way to go. You should use Absolute References ($A$1) for both row and column so you can drag the formula across rows and columns without having the reference changing.

    There is also a typo in Mark's formula.

    =IF(INDIRECT("'["&$A$1&"]MONTHLY TIME SHEET'!$G$16")>0,INDIRECT("'["&$A$1&"]MONTHLY TIME SHEET'!$G$16"),"")

  4. #4
    BoardCoder
    Licensed Coder VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    622
    Location
    There is also a typo in Mark's formula.
    Figures - I'm dangerous near a keyboard
    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net

  5. #5
    VBAX Newbie
    Joined
    Jun 2004
    Posts
    5
    Location
    At the risk of sounding like a teenager (fat chance at my age)...you guys rock!!

    It works BUT.....I have another problem.

    If the master cell (say) $A$1 is the exact filename "Name-Jan.xls" then it works fine.

    Unfortunately I have 'built' the filename in $A$1 using the CONCATENATE function. It takes the 'name' from one cell and combines with the 'month' from another to 'Build a complete filename in $A$1

    If I do that I get a #REF error in the formula cell.

    I could possibly work round things as they are, but would be nice to know if you have any ideas how my problem might be addressed as it stands.

    Thanks once again for a very SPEEDY response.

    Regards

    Paul


  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hi Paul,

    Post the formula you have in A1.

    You will get the #REF! error when/if you are referencing certain cells in a formula and delete any of the precedents.

    Example, do this; type 10 in A1, type =A1 in cell B1. They should now match. Now select and delete the entire column A. B1 will shift left and is now A1, but the reference to the formula has been deleted so you will get the #REF! error.

    That's why this is a dependent issue.

Posting Permissions

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