Solved

Excel Find and Replace Issues

Posted on 2011-03-21
16
899 Views
Last Modified: 2012-06-21
I have to replace formulas in Excel from 2010_2012 to 2011_2012.  Sounds simple enough right?
For whatever reasons Excel wants me to save/update each individual cell while it tries to replace them.  Since I have over 100,000 replacements to make across a bunch of sheets that won't fly.

Is there a way to use find and replace so it only worries about replacing the formulas and not saving each cell.   Yes I have selected all cells to be replaced at once, still the same problem.


Thanks.
0
Comment
Question by:Amerilab
16 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 35180841
You shouldn't get any prompts if the replacement formula is correct - does the 2011_2012 sheet exist?
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 35180850
Untested

Try this

Sub Sample()
    Dim oRange As Range, aCell As Range, bCell As Range
    Dim ws As Worksheet
    Dim ExitLoop As Boolean
    Dim SearchString As String, ReplaceString As String
    
    On Error GoTo Err
    
    '~~> Change this to the respective Sheet
    Set ws = Sheets("Sheet1")
    
    Set oRange = ws.Cells

    SearchString = "2010_2012"
    ReplaceString = "2011_2012"
    
    Set aCell = oRange.Find(What:=SearchString, LookIn:=xlFormulas, _
                LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False)
    
    If Not aCell Is Nothing Then
        Set bCell = aCell
        aCell.Formula = Replace(aCell.Formula, SearchString, ReplaceString)
        Do While ExitLoop = False
            Set aCell = oRange.FindNext(After:=aCell)

            If Not aCell Is Nothing Then
                If aCell.Address = bCell.Address Then Exit Do
                aCell.Formula = Replace(aCell.Formula, SearchString, ReplaceString)
            Else
                ExitLoop = True
            End If
        Loop
    End If
    
    MsgBox "Done"
    
    Exit Sub
Err:
    MsgBox Err.Description
End Sub

Open in new window


Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35180853
CrossOver.

Sid
0
 

Author Comment

by:Amerilab
ID: 35180937
Before I try anything I forgot to mention that I copied this folder from last years and renamed it to this years.  

Example:  Budgets 2010_2011  was copied and pasted then renamed to Budgets 2011_2012.

Now I am trying to update the formulas in the copied folder to 2011_2012.  

The dumbest thing is when I use the find a replace and put quotes in the replace part it goes through the whole sheet with out asking for a save.  



Untitled.png
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35180971
If You manually do it, and if the folder doesn't exist then it will prompt you. Hence use the code that I gave above and ensure that the replacement string is correct.

Sid
0
 

Author Comment

by:Amerilab
ID: 35180990
One more thing,  I guess it's not asking to save it, but update the values.  It's looking for a sheet to pull it from, I'd rather skip this and get the formulas updated first.  If there is a way please help.

Thank you.
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35181024
>>>One more thing,  I guess it's not asking to save it, but update the values.  It's looking for a sheet to pull it from, I'd rather skip this and get the formulas updated first.  If there is a way please help.

I already gave you the code ;) See above

Sid
0
 
LVL 5

Expert Comment

by:Kannan253984
ID: 35181149
Hi,

if you want to replace the string in formulas, you can't do directly, you will have to check the Option in option dialog window ==> Advanced ==> Show formulas in cells instead of their calculated results.

then come to your sheet, now you can do your find and replace, then resume back the formula settings.

refer the image [excel 2010]

KK.
EditExcelFormula.png
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Amerilab
ID: 35181175
Is there a way to do run this MACRO on other workbooks?  


Set ws = "what ever the current workbook is"
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35181191
Amerilab: First things first :)

1) Did you try it and did it work?

>>>Is there a way to do run this MACRO on other workbooks?

2) Yes, However, I will come to this once you answer the above question. :)

Sid
0
 

Author Comment

by:Amerilab
ID: 35181211
Kannan,

That way does show the formulas, but I still get the message to update each cell.
0
 

Author Comment

by:Amerilab
ID: 35181228
I believe it did, however these excel sheets are not something we would like a Macro attached to.  
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35181239
So do you want to use a VBA Method or Manual Method?

Sid
0
 

Author Comment

by:Amerilab
ID: 35181271
The way our CFO showed me how to do this was with the find and replace feature.  It used to work, like I said with

FIND:                 2010_2011
REPLACE :        "2011_2012"

But it adds the quotes to the formula too, but now when I hit "replace all" it still goes one cell at a time without the prompt for update.  
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35181460
If you are doing it manually

1) In the replace you do not need the quotes
2) Select "Look in In Formulas" rather that in Values

See how the code above looks in formulas rather than values.

Sid
0
 

Author Comment

by:Amerilab
ID: 35182496
The problem was right in my face the whole time.   I needed to update the links for each workbook.  
Thank you for all your help today.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now