Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
programmaticly change code
I want to have a hard coded value for a variable and then
be able to use code to alter the hardcoded value. I have seen advice regarding how to get basic info like the number of lines of code in a routine etc but nothing that shows how to find & replace a line of code with new code. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
programmaticly change code
Bruce,
Try something like the following. It will change the first occurrence in Module2 of X = 123 to X =234 Dim SL As Long Dim EL As Long Dim SC As Long Dim EC As Long Dim Found As Boolean With ThisWorkbook.VBProject.VBComponents("Module2").Cod eModule SL = 1 EL = .CountOfLines SC = 1 EC = 1024 Found = .Find("X = 123", SL, SC, EL, EC, True, False, False) If Found = True Then .DeleteLines SL .InsertLines SL, "X = 234" End If End With -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com "bruce" wrote in message ... I want to have a hard coded value for a variable and then be able to use code to alter the hardcoded value. I have seen advice regarding how to get basic info like the number of lines of code in a routine etc but nothing that shows how to find & replace a line of code with new code. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I change this code? | Excel Discussion (Misc queries) | |||
VBA Code to Change the Tab Name | Excel Discussion (Misc queries) | |||
VBA Code to Change the Tab Name | Excel Discussion (Misc queries) | |||
combo box on change code | Excel Discussion (Misc queries) | |||
Change to Code | Excel Programming |