find and replace text within a known module

jarhead58

Active Member
Joined
Sep 21, 2017
Messages
367
Office Version
  1. 2021
Platform
  1. Windows
Hey all!!

I have a form that opens when I open a workbook. I use the form to open another workbook via a drop down list. I use Select Case to open the chosen option. What I'm looking to do is change wording in a module in the first opened workbook. How would I use the Find..Replace method and is it possible?
For instance, the option chosen is "x.xlsm". I then want to access a module from within the first workbook opened and change a line with "y.xlsm" to "x.xlsm" TIA
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Any problems with me cross-posting this in another forum? I'd like to get this solved working or not. I'll wait until I get an ok. TIA
 
Upvote 0
I must admit, I am not 100% clear on exactly what you are trying to do. Are you trying to create VBA code that updates the VBA code in another workbook?
 
Upvote 0
Yes. When the choice is made from the form, it opens a 2nd workbook. Then I need it to update a module with different text within the main workbook.

I must admit, I am not 100% clear on exactly what you are trying to do. Are you trying to create VBA code that updates the VBA code in another workbook?
 
Upvote 0
Is it just a specific module (if so, what is the name) and specific procedure (if so, what is that name) that you are looking to update?

This might be helpful, especially the part entitled "Searching for Text in a Module": http://www.cpearson.com/excel/vbe.aspx
 
Upvote 0
Is it just a specific module (if so, what is the name) and specific procedure (if so, what is that name) that you are looking to update?

This might be helpful, especially the part entitled "Searching for Text in a Module": http://www.cpearson.com/excel/vbe.aspx

You know, I screwed the pooch on this. I was trying to fix 2 different things at once, what an idjut lol!! Ok, it is actually on sheet1 and the procedure is called ChangeSheet. This would be done in the main workbook. My apologies for misleading everyone, not my intentions lol! I'm doing what I hate that others do, not focusing on the main issue. Here is the corrected version.

"I have a form that opens when I open a workbook. I use the form to open another workbook via a drop down list. I use Select Case to open the chosen option. What I'm looking to do is change wording in a procedure called ChangeSheet in the first opened workbook. How would I use the Find..Replace method and is it possible?
For instance, the option chosen is "x.xlsm". I then want to access a procedure called ChangeSheet from within the first workbook opened and change text with "y.xlsm" to "x.xlsm" TIA
"
 
Upvote 0
To be honest, I have never really written VBA code to update other VBA code, so I would have to defer to the link I provided and the expertise of others who have tried to do it in the past. I think it can often get a little complicated.

Typically, when creating VBA code, you want to program it in a manner so that the code does not require constant updating. If you have values that can change, it is better to use parameters that you feed into your procedures (i.e. your procedure would have a parameter for the file name). Is that feasible?
 
Upvote 0
To be honest, I have never really written VBA code to update other VBA code, so I would have to defer to the link I provided and the expertise of others who have tried to do it in the past. I think it can often get a little complicated.

Typically, when creating VBA code, you want to program it in a manner so that the code does not require constant updating. If you have values that can change, it is better to use parameters that you feed into your procedures (i.e. your procedure would have a parameter for the file name). Is that feasible?

I think I'm over thinking it! I think I'll just use a Select Case for the different options within the ChangeSheet procedure. I'll see if that makes it easier. Thanks for the help Joe4!!
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top