inserting a formula and autofill based on other columns

TheLSD

New Member
Joined
Jan 12, 2022
Messages
33
Office Version
  1. 2010
Platform
  1. Windows
I have a formula and code that recorded from recording the process

here's my code:
VBA Code:
Sub Status()
Sheets(1).Range("D6").FormulaR1C1 = "=IFERROR(VLOOKUP(RC3,'Form Capex HRGA'!R6C3:R2000C12,4,0),IFERROR(VLOOKUP(RC3,'Form Capex HRGA'!R6C5:R2000C12,2,0),IFERROR(VLOOKUP(RC3,'Form Capex IT'!R6C3:R2000C12,4,0),IFERROR(VLOOKUP(RC3,'Form Capex IT'!R6C5:R2000C12,2,0),IFERROR(VLOOKUP(RC3,'Form Capex LDD'!R6C3:R2000C12,4,0),IFERROR(VLOOKUP(RC3,'Form Capex LDD'!R6C5:R2000C12,2,0),IFERROR(VLOOKUP(RC3,'Form Capex" & _
        "C3:R2000C12,4,0),VLOOKUP(RC3,'Form Capex NPD'!R6C5:R2000C12,2,0))))))))"
Selection.AutoFill Destination:=Range("d6:d" & Range("c" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
End Sub

I modified it by changing the selection autofill to match by the number of filled C column, but when I try to run it, the code always shows run time error 1004 and highlight the formula part.
When I try to change back what it recorded, still won't make it up and the formula part also highlighted

what did I do wrong? I just want the code to insert d6 a formula and autofill based on numbers of data in column c (if there're 100 data on column c then the autofill will go down to 100 also, seems this is called dynamic range but I'm not sure)

thank you
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I have a formula and code that recorded from recording the process

here's my code:
VBA Code:
Sub Status()
Sheets(1).Range("D6").FormulaR1C1 = "=IFERROR(VLOOKUP(RC3,'Form Capex HRGA'!R6C3:R2000C12,4,0),IFERROR(VLOOKUP(RC3,'Form Capex HRGA'!R6C5:R2000C12,2,0),IFERROR(VLOOKUP(RC3,'Form Capex IT'!R6C3:R2000C12,4,0),IFERROR(VLOOKUP(RC3,'Form Capex IT'!R6C5:R2000C12,2,0),IFERROR(VLOOKUP(RC3,'Form Capex LDD'!R6C3:R2000C12,4,0),IFERROR(VLOOKUP(RC3,'Form Capex LDD'!R6C5:R2000C12,2,0),IFERROR(VLOOKUP(RC3,'Form Capex" & _
        "C3:R2000C12,4,0),VLOOKUP(RC3,'Form Capex NPD'!R6C5:R2000C12,2,0))))))))"
Selection.AutoFill Destination:=Range("d6:d" & Range("c" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
End Sub

I modified it by changing the selection autofill to match by the number of filled C column, but when I try to run it, the code always shows run time error 1004 and highlight the formula part.
When I try to change back what it recorded, still won't make it up and the formula part also highlighted

what did I do wrong? I just want the code to insert d6 a formula and autofill based on numbers of data in column c (if there're 100 data on column c then the autofill will go down to 100 also, seems this is called dynamic range but I'm not sure)

thank you
I just fix the problem of the formula because of the incompleteness. Now the highlighted part move to the next row, any ideas which part I do wrong?
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

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