Link to home
Start Free TrialLog in
Avatar of Mattie Owens
Mattie Owens

asked on

Copying formula down column

I am trying to copy a formula in a range of cells. I placed the worksheet activate and nothing is happening. What am I missing.


Private Sub Worksheet_Activate()
Range("B6").Select

Range("B10:B1000").Formula = "=IFERROR(MID(C17,FIND(" * ",SUBSTITUTE(C17," \ "," * ",LEN(C17)-LEN(SUBSTITUTE(C17," \ ",""))))+1,LEN(C17)),"")"
Range("D10:D1000").Formula = "=LEFT(B10,10)"

End Sub
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Where have you placed that code? It should be placed on the Sheet Module of the Sheet which will be activated.
So if you want to run this code when say Sheet2 gets activated, right click the Sheet2 Tab --> View Code --> Place the code into the opened code window --> Save your workbook as Macro Enabled Workbook.

Also, the line which places the formula should be like this...

Range("B10:B1000").Formula = "=IFERROR(MID(C17,FIND(""*"",SUBSTITUTE(C17,""\"",""*"",LEN(C17)-LEN(SUBSTITUTE(C17,""\"",""""))))+1,LEN(C17)),"""")"

Open in new window

Also, this will only work if you are on another sheet and you return to this sheet.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.