+ Reply to Thread
Results 1 to 9 of 9

Count and Then Replace Occurrences in Formulas with VBA

  1. #1
    Registered User
    Join Date
    08-03-2010
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    Count and Then Replace Occurrences in Formulas with VBA

    I have a master spreadsheet with ~15,000 links to about 20 external files.

    The 20 external files are generated through another macro process and when they are created have a new version number appended (e.g. 04.12). In the master spreadsheet, I need to edit and replace the version number each each time the support files are updated. So for example, replace 04.12 with 04.13. What I would like to do is two things:

    1) Count the occurrences of the version number
    2) Replace the version number based on a value.

    I am currently doing the replacement with a recorded macro and this code:
    Please Login or Register  to view this content.
    What I can't figure out is how can I count all of the cells where the formula contains the version number (e.g. 04.12) and then loop through those and keep a counter in the status bar so I can see how far along it is. The code above works, but I recently just upgraded to 2007 and this process now takes so long, I want to be able to show progress at the bottom to the users.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Count and Then Replace Occurrences in Formulas with VBA

    What column are you trying to update the version in and what row does your data start on? Can you upload a cutdown copy of your wb
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    08-03-2010
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Count and Then Replace Occurrences in Formulas with VBA

    The cells start in column Z and goes to AI and the rows start in 326 and goes to 3010. The data is not, however, all together, so there's spaces in the between the rows when there's major changes in the data sources. I don't think that would matter, though.

    I can try to upload part of the file, but will need to cut it down quite a bit.

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Count and Then Replace Occurrences in Formulas with VBA

    So the Version can be in Column Z to AI?

  5. #5
    Registered User
    Join Date
    08-03-2010
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Count and Then Replace Occurrences in Formulas with VBA

    Yes, the formulas with the version numbers to be replaced are in in col Z to col AI.

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Count and Then Replace Occurrences in Formulas with VBA

    When you say Formulas, are they formulas o are they Values/Text?

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-03-2010
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Count and Then Replace Occurrences in Formulas with VBA

    They are formulas. So for example, here's what is in row 326:

    Please Login or Register  to view this content.
    So in the above, I'm looking to count all the cells were a 04.12 exists and then ultimately replace it with 04.13.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Count and Then Replace Occurrences in Formulas with VBA

    have you considered using indirect() and putting the new version in a specific cell somewhere? that way, you would see which version you were working with last, and just by changing the cell, the links would update?

    hmm om 2nd thoughts, indirect requires the files to be open for them to update/calc
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  9. #9
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Count and Then Replace Occurrences in Formulas with VBA

    Ive tried but having some trouble. How about turning Calculation mode off at the start of your code and turn it back on at the end. Then the status bar should show a Calculation percentage

    Please Login or Register  to view this content.

+ 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