+ Reply to Thread
Results 1 to 3 of 3

How to update sheet references in excel formula?

  1. #1
    Registered User
    Join Date
    12-10-2012
    Location
    Calgary,AB
    MS-Off Ver
    Excel 2003
    Posts
    3

    How to update sheet references in excel formula?

    I am having trouble updating a sheet reference in a database.

    The format of my formula is like so:
    =(SUMIF('Raw Data'!$B:$B,"P0900",'Raw Data'!D:D))

    I want to write a macro to update the "Raw Data" worksheet so that a new one will be created according to the selected date (and it will be renamed correspondingly).
    I tried to use the indirect function so that the formula becomes

    =(SUMIF(indirect(raw_data_sheet_name&$B:$B),"P0900",indirect(raw_data_sheet_name&$D:$D))

    where raw_data_sheet_name changes based on the date.

    This method would work except that I have thousands of cells to update. I tried using the find and replace function in excel but it doesn't work since it would make the formula incomplete.

    Is there a macro I can use to solve this?

    Thanks!

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to update sheet references in excel formula?

    If you been able you use one sheet for all data, you can use pivot table to do the work for you.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    12-10-2012
    Location
    Calgary,AB
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How to update sheet references in excel formula?

    I don't know if there is an easier way but this is how I solved this problem:
    1. I converted the formulas to non formulas by using Excel's find and replace for the "=" sign and replacing it with an arbitrary string.
    2. To convert the sheet names I simply used find and replace.
    3. To put brackets and quotes around the ranges, I used a macro that used the instr() function to find the location of the ranges, and used an insert string function (can be easily found online) to insert the quotes and brackets at the corresponding indexes.

    Hope this helps anyone viewing this post.

+ 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