Vba: inserting formula with variables and other sheets in a cell, errr 1004

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I need to write in a cell the following formula.
Consider Excel in italian language:
SCARTO is OFFSET
INDICE is INDEX
CONFRONTA is MATCH

VBA Code:
dim calculate as string
calculate = "=SCARTO(INDICE('Sheet1'!" & ccode.Address & ";CONFRONTA('Sheet2'!" & z & ";'Sheet1'!A:A;0);CONFRONTA('Sheet2'!" & ColumnLetter & "4;'Sheet1'!1:1;0));0;1)"
Sheets("Sheet10").Cells(ro, col).Formula = calculate

Error on the last line:
VBA Code:
VBA Runtime Error 1004 Application-defined or Object

Any ideas?
 
If you’re adding the same column for all rows, just add or subtract from the column match function result as needed.

Fantastic!

Easier then expected:

=MATR.SOMMA.PRODOTTO(SOMMA.SE(Sheet1!B1:B41;A2:A5;INDICE(Sheet1!A1:CS41;0;CONFRONTA(C1;Sheet1!5:5;0)+1)))

Thank's so much.
 
Last edited by a moderator:
Upvote 0

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,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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