Macro Help - copy, replace, paste, next

JayEmerson

New Member
Joined
Jul 9, 2009
Messages
1
I'm trying to save time and generate a script to prepare OFFSET and INDEX formulas and apply with defined Names. My MAIN worksheet has 55 zip codes with references to their columns in Z-DATA worksheet. One column is the monthly median price history; the other is the monthly momentum (EMA) based on the monthly price history.

E.g., in the MAIN worksheet:

------A----------B-------------------C---------------------------------------------------------------
1 -- 90101 -- Z_ZIP_mom -- =OFFSET('Z-Data'!$mmm$2,1,0,COUNT('Z-Data'!$mmm$3:$mmm$2000),1)
2 -- AC -- Z_ZIP_nbr -- =OFFSET('Z-Data'!$nnn$2,1,0,COUNT('Z-Data'!$nnn$3:$nnn$2000),1)
3 -- AA -- Z_ZIP_pt -- =INDEX(Z_ZIP_nbr,COUNTA(Z_ZIP_nbr))

The desired end result is to have 3 defined names added to the Name Manager for each zip code

(e.g.,
Z_90101_mom, =OFFSET('Z-Data'!$AC$2,1,0,COUNT('Z-Data'!$AC$3:$AC$2000),1)
Z_90101_nbr, =OFFSET('Z-Data'!$AA$2,1,0,COUNT('Z-Data'!$AA$3:$AA$2000),1)
Z_90101_pt, '=INDEX(Z_90101_nbr,COUNTA(Z_90101_nbr))

I need to replace five occurrences of ZIP with the contents of A1. I need to replace three occurrences of "mmm" with the contents of A2. I need to replace three occurrences of "nnn" with the contents of A3. Then I need to define the names for each of the 3 in column B. Lastly, I need to proceed down to the next zip code on the MAIN worksheet.

I can't find any help or examples where the contents of a cell (NOT an entire cell) can be copied and pasted in the Replace dialog box AND being able to iterate the process for the next zip code.

:confused:
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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