+ Reply to Thread
Results 1 to 11 of 11

How to Bulk Edit a Formula Using VBA

  1. #1
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    How to Bulk Edit a Formula Using VBA

    I am trying to mass-edit formulae using the Find and Replace feature, however, Excel keeps popping up and telling me the formula is not correct (which I know as I need to edit the front end and the back end of each formula).

    Screen Shot 2018-08-06 at 11.17.48.png

    Can somebody tell me how to turn this off as it keeps reversing the changes I make. I need to edit both sides of 100 formulae without changing the middle part and this is causing me untold grief.

    Thanks in advance.
    Last edited by doubleuson; 08-06-2018 at 07:41 AM. Reason: Solve Change

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Turn Off Formula Error

    You have made a mistake editing your formula. What changes are you trying to make?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,887

    Re: Turn Off Formula Error

    You can't force Excel to do something it's not going to be able to do (that's why it has error messages - it's saying to you, "You can't do this in Excel."). You will need to find a different way. What EXACTLY are you trying to do?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Turn Off Formula Error

    Use Excel Vba to change your formula as text.

    Then do find and replace which won't throw any error since the formula's are resides as text.

    After completing the process re-instate those text (formula's) showing as text to Real formula.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  5. #5
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Turn Off Formula Error

    Quote Originally Posted by Glenn Kennedy View Post
    You have made a mistake editing your formula. What changes are you trying to make?
    Quote Originally Posted by AliGW View Post
    You can't force Excel to do something it's not going to be able to do (that's why it has error messages - it's saying to you, "You can't do this in Excel."). You will need to find a different way. What EXACTLY are you trying to do?
    Screen Shot 2018-08-06 at 11.31.23.png

    I am trying to bulk edit an IF function to test whether the value in cell D is 0, to remove the #DIV/0! error in multiple formulae at once. Everytime I try to change the front end, it says I have a missing parentheses at the end and undoes my changes. So then I try to add a parentheses to the end and it won't let me because incorrect formula.

    I am not about to go through each one of them and painstakingly make those changes.

  6. #6
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Turn Off Formula Error

    Quote Originally Posted by :) Sixthsense :) View Post
    Use Excel Vba to change your formula as text.

    Then do find and replace which won't throw any error since the formula's are resides as text.

    After completing the process re-instate those text (formula's) showing as text to Real formula.
    See, that's a decent suggestion. How would I go about doing it in VBA?

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,887

    Re: Turn Off Formula Error

    I am not about to go through each one of them and painstakingly make those changes.
    Nor should you have to, however you can't do what you want with Find & Replace for the reasons already explained, whether you like it or not. Maybe go with the VBA suggestion.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: How to Bulk Edit a Formula Using VBA

    Using the replace dialog, replace = with something that won't be part of the formula (e.g. a pipe | character) so that the formula is not a real formula. Then make your changes as needed, then replace | with = to make them actual formulas again.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,887

    Re: How to Bulk Edit a Formula Using VBA

    I've taken the liberty of giving your thread a decent title and moving it to the VBA section, as we now know that is what you are going to need to solve this.

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: How to Bulk Edit a Formula Using VBA

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: How to Bulk Edit a Formula Using VBA

    /SOLVED

    Thanks for all your help.

    By all means have a look and a crack at any of my (many) other issues. Life is hard as an Excel novice:

    https://www.excelforum.com/excel-pro...ith-macro.html

    https://www.excelforum.com/excel-for...istance-2.html

+ 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] How to turn #N/A error into 0?
    By QuantEdge in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-23-2017, 11:50 AM
  2. Turn off error sounds
    By Graham Griggs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2016, 05:24 PM
  3. Turn Off Error Messages
    By NatalieEC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2015, 12:34 PM
  4. Turn formula into a function to eradicate #VALUE! error
    By dataman22 in forum Excel General
    Replies: 4
    Last Post: 09-10-2014, 04:12 PM
  5. Auto calc on, then turn off, then runtime error how to turn back on
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2011, 10:37 AM
  6. Can't turn off Invalid References Error
    By sithlorderic in forum Excel General
    Replies: 4
    Last Post: 08-24-2011, 03:52 PM
  7. [SOLVED] Way to Turn Off Error Checking on a Range?
    By James Cox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2005, 03:06 PM

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