Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey all,
Well it's not Thanksgiving yet...so there's work to be done, ahh ok my work. I have spent the last couple of days trying to figure out why my procedure never ends, and I still can't seem to figure it out. My goal is to use the procedure below to Find/Replace a line of code from the Code Module. (I've looked at it for a while and it seems simple enough but I've had my hands involved in it so it's probably missing a key ingredient...like "if false then, exit sub, end if"). Here's the code from module 1-- Sub FindChange() Dim I As Long Dim myProject As VBProject Dim myComponent As VBComponent Dim myModule As CodeModule Dim StartLine As Long, StartColumn As Long Dim EndLine As Long, EndColumn As Long Dim strNewDestination As String Dim strFind As String strFind = "'BOOKMARK" strNewDestination = "Set wks = wkb.worksheets(""Sheet3"") 'BOOKMARK" Set wkb = ThisWorkbook Set myProject = wkb.VBProject Set myComponent = myProject.VBComponents("Module2") Set myModule = myComponent.CodeModule With myModule While .Find(strFind, StartLine, StartColumn, EndLine, EndColumn, False, False, False) ..ReplaceLine StartLine, strNewDestination StartLine = StartLine + 1 Wend End With End Sub 'Here's the code from Module 2 -- Sub One() Set wks = wkb.Worksheets("Sheet1") 'BOOKMARK End Sub My thanks to anyone able digest this mystery and bring forth new truth and understanding to the VBE, VBA's inner sanctum. MattS |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Replace module with code | Excel Programming | |||
find and replace - replace data in rows to separated by commas | Excel Worksheet Functions | |||
Using Find and Replace to replace " in a macro | Excel Programming | |||
Replace method - cannot find any data to replace | Excel Programming | |||
Macro to replace a VBA module? | Excel Programming |