VBA Loop(?) that Copies a Tab and Find/Replace Text String

kirklj

New Member
Joined
Jan 10, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Greeting!

I am in need of some help with constructing a macro. I've built a workbook containing a table similar to the following:

Company NameDirectory Path
Company BPath B
Company CPath C
Company DPath D
Company EPath E
Company FPath F
Company GPath G

And among several other tabs in the workbook, there is a template tab named “Company A” that will need to be copied. Also, the data link in the sheet are specific to Company A. That said, the macro should be able to perform the following:

  1. Copy template tab "Company A", and then place the copied tab after the "Company A” tab.
  2. Rename the copied tab to "Company B" and then Find/Replace Directory Path A with Path B.
  3. Repeat step 1 but place the copied tab after the "Company B” tab. **
  4. Repeat step 2, but with the “Company C” tab name and directory path.
  5. Continue to loop through the Company Name - Directory Path table indefinitely until each company is represented with its own tab. (This table will continue to grow.)
**NOTE: For each subsequent copy of template tab "Company A", the copied tab will need to go to the "back of the line" so that when the macro concludes, the tab order is Company A followed by Company B followed by Company C, etc.

Thanks in advance for your help! It is greatly appreciated…..
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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