+ Reply to Thread
Results 1 to 6 of 6

Automating weekly formula changes

  1. #1
    Valued Forum Contributor scaffdog845's Avatar
    Join Date
    02-01-2008
    Location
    Aston, PA. USA.
    MS-Off Ver
    Microsoft 365
    Posts
    373

    Thumbs up Automating weekly formula changes

    Morning all,

    The attached workbook is a follow up report that gets run every Friday. There are 1092 cells that contain formulas that reference a file that was created on Wednesday of the same week. eg.
    Please Login or Register  to view this content.
    etc.

    When I run the report, I would do a find and replace within the entire workbook and replace 12-2-09 with 12-9-09 to get the above formula. Other people may need to run this report in the future and I would like to automate this formula change.

    I was hoping that on the opening of the file the user would be presented with a simple 2 line form.

    What was last Wednesday's date?
    What was this Wednesday's date?

    If both questions are answered, all replacements would be made without intervention. The user should also have the ability to cancel out of the form without making any formula changes.
    Last edited by scaffdog845; 12-15-2009 at 09:04 AM.
    Click here to read the Forum Rules
    Whatever it is in life you decide to go after, go after with great ferocity.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Automating weekly formula changes

    This one was a bit tricky for me. First, I wasn't able to do it on your example, because I can only use excel 03 files (.xls). So you may have to modify the code. Right now I have it checking the first 1092 rows on the 1st column, but those numbers can be changed easily.

    One thing to remember is the "Last Wednesday's Date" will have to be typed in the Input Box EXACTLY as it appears in the formula. I've tested on a sheet of my own and this code works great for me. Let me know if it works for you.

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Valued Forum Contributor scaffdog845's Avatar
    Join Date
    02-01-2008
    Location
    Aston, PA. USA.
    MS-Off Ver
    Microsoft 365
    Posts
    373

    Re: Automating weekly formula changes

    dave

    I'm just leaving work for the day. I may not get a chance to try it until Monday. I'll repost with the results then. thanx for looking into it!!!

  4. #4
    Valued Forum Contributor scaffdog845's Avatar
    Join Date
    02-01-2008
    Location
    Aston, PA. USA.
    MS-Off Ver
    Microsoft 365
    Posts
    373

    Re: Automating weekly formula changes

    dave

    I had a quick chance to try it here at home tonight. Unfortunately, without thinking, I didn't have access to the linked file for a new week because it is on my work network. I had to hit cancel 900 plus times for linking to the file. I should have created a mock file with the correct name....


    Anyway, it seemed to work but only on the Totals! sheet. What modifications would be needed to have the code make the same changes to all three sheets in the workbook?

    The changes are only needed in M2:M50 on Plant Section Sort! M2:M50 on Work Center Sort! I2:I3 and J2:J1000 on Totals! However it seemed to run fine with the wildcard range you had for the Totals! sheet.

    Thanks

  5. #5
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Automating weekly formula changes

    The procedure is set up to work on whichever sheet is active. To set it to work on different sheets, write Sheets("YourSheetName").Activate somewhere before the For... loop.

    Next, to work on different columns and rows, use the For i = ... and For j = .. to set different ranges. The i controls the rows and the j controls the columns.

    For example, to run on a tab named "Plant Section Sort" M2:M50 and a tab named "Work Center Sort" M2:M50, the code could look like this:

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor scaffdog845's Avatar
    Join Date
    02-01-2008
    Location
    Aston, PA. USA.
    MS-Off Ver
    Microsoft 365
    Posts
    373

    Re: Automating weekly formula changes

    davegugg

    Thanks for the followup. I was able to set it to work for all the sheets on exactly the ranges i needed. I appreciate the extra directions to help me tweak it. Have a great holiday season!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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