View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default Find and Replace in Formulas

This works in Excel 2000 (not sure how it will work in office XP)

The code defines the range containing cells with formulas
Yhan it changes all cells with formulas.
change "i" & "z" to what you need.

You can do it cell by cell with the second code.

============================
Dim rng As Range, wks As Worksheet,

For Each wks In ThisWorkbook.Worksheets

On Error Resume Next
Set rng = wks.Cells.SpecialCells(xlCellTypeFormulas, 23)
If Not rng Is Nothing Then
rng.Replace What:="i", Replacement:="z", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End If
Set rng = Nothing
Next
======================================
Dim cel as rng rng As Range, wks As Worksheet,

For Each wks In ThisWorkbook.Worksheets

On Error Resume Next
Set rng = wks.Cells.SpecialCells(xlCellTypeFormulas, 23)
If Not rng Is Nothing Then
For each cel in rng
cel.Replace What:="i", Replacement:="z"
End If
End If
Set rng = Nothing
Next
==========================

hope this is what you are looking for.
--
steveB

Remove "AYN" from email to respond
"prkhan56" wrote in message
ups.com...
Hello Steve,
Thanks for your reply. But I am a newbie and I dont know how make the
coding..thats why I was searching for help in the groups.

Thanks

Rashid Khan

STEVE BELL wrote:
I recorded this in Excel 2000

Selection.SpecialCells(xlCellTypeFormulas, 23).Select

This finds only cells with formulas

You cound loop through each worksheet
select specialcells
than loop through each cell in selection
Compare cell formula for what you are searching to change
change formula

--
steveB

Remove "AYN" from email to respond
"prkhan56" wrote in message
oups.com...
Hello All,

I am using Office XP and have a problem.

I have a workbook with many sheets where I had defined global range
names for eg

xxxxData (xxxx = variable lengths of Alphabets from A to Z)

Now for some reason I need to change it to local range names for eg
xxxx!Data

and also replace "" (double quotes) used with an IF formula to
"NA"

The range names are used in various Vlookup Formulas.

Is there a macro to search each formula and change xxxxData to
xxxx!Data or simply replace the word Data with !Data and also replace
"" to "NA"..on all the sheets in the workbook

I searched "" and replaced it with "NA" which worked with
Replace All.

I tried the following with Find and Replace:
Find: Data
Replace with: !Data

but I cannot use Replace All ...for some reason it gives me error and
have to do it one by one which works...but with so many sheets doing
manually is taking me a long time to do it.

Any help would be appreciated

TIA

Rashid