Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have about 200 files where I need to change one word in the code
from "prop" to "east". Instead of opening each file and doing it manually, it would be great if I could write a macro to rewrite the code for me. Here's what I have so far which Finds the word in the code. But I do not know how to go about replacing it. Dim VBProj As VBIDE.VBProject Dim VBComp As VBIDE.VBComponent Dim CodeMod As VBIDE.CodeModule Dim FindWhat As String Dim ReplaceWhat As String Dim SL As Long ' start line Dim EL As Long ' end line Dim SC As Long ' start column Dim EC As Long ' end column Dim Found As Boolean Set VBProj = ActiveWorkbook.VBProject Set VBComp = VBProj.VBComponents("Thisworkbook") Set CodeMod = VBComp.CodeModule FindWhat = "prop" ReplaceWhat = "east" With CodeMod SL = 1 EL = .CountOfLines SC = 1 EC = 255 Found = .Replace(target:=FindWhat, replacement:="east", StartLine:=SL, StartColumn:=SC, _ EndLine:=EL, EndColumn:=EC, _ wholeword:=True, MatchCase:=False, patternsearch:=False) End With Any help is appreciated. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Replacing Code with words using vlookup | Excel Programming | |||
question about excessive code in replacing #N/A when using VLOOKUP | Excel Discussion (Misc queries) | |||
Replacing VBA code strings by using VBA code? | Excel Programming | |||
Replacing code at runtime | Excel Programming | |||
Replacing code at runtime | Excel Programming |