vba formulas

tjharlan

Board Regular
Joined
May 8, 2004
Messages
63
Hi,

I have a macro that inserts a formula. Once the formula is inserted, I want to use autofill to "copy" the formula down. My problem is that the formula is not copying down correctly (it keeps the "n2" rather than "n3", "n4", etc.).

'code blows up
Formula1:="=INDIRECT(SUBSTITUTE(n2,"" "",""_""))"

'compile error
Formula1:="=INDIRECT(SUBSTITUTE("n2","" "",""_""))"

'works, but, when i copy and autofill formula down, the value stays as "n2"...when I want it to go to "n3"..."n4"..."n5"...etc.
Formula1:="=INDIRECT(SUBSTITUTE(""n2"","" "",""_""))"

Thanks for any help with the proper syntax.

T.J.
 
All I can say again is that the formula could be wrong.

What do you get when you enter the formula into a cell on the worksheet?

Can you actually give an example of your data?
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,216,031
Messages
6,128,422
Members
449,450
Latest member
gunars

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