# PUT A FORMULA INTO A VARIABLE

#### gab

##### New Member
HI!!

I have the following formula

Activecell.FormulaR1C1 = "=CELL(""row"",INDEX(C[-2],MATCH(""INTEREST:"",C[-2],0)))"

And is working and allocating the result into a cell, but i want the result fo the formula into a variable for working in vba i.e X = "=CELL(""row"",INDEX(C[-2],MATCH(""LATE INTEREST & BK FEES :"",C[-2],0)))" and i just dont know how to do it

Thanks for any help!

### Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

#### Anthony47

##### Well-known Member
Hello gab.
Both INDEX and MATCH can be exploited in vba using Application.WorksheetFunction; for example:
VAR1 = Application.WorksheetFunction.index(1,2)

Of course you can use Application.WorksheetFunction.match(arg, matr, 0) as an argument for Application.WorksheetFunction.index

Does this help? Bye.

#### gab

##### New Member
Thanks for your reply (because i needed that code for other stuff), but for in this case is different...let me explain more:

First I had a formula which put the resul into a cell. the initial code (and IT WORKS BUT I DONT WANT IN A CELL!) was:

Cells(3,13). Activate
ActiveCell.FormulaR1C1 = "=CELL(""row"",INDEX(C[-2],MATCH(""LATE INTEREST & BK FEES :"",C[-2],0)))"

a = Cells(3, 13)
But as you see...the result is allocating in a cell, not in a variable (AND I WANT INTO A VARIABLE!,,and dont know how!). I would like something like this:

a = CELL("row",INDEX(C[-2],MATCH(""LATE INTEREST & BK FEES :"",C[-2],0)))

so the variable "a" will be equal to the formula. And that's the issue!!! thanks for any help!

#### gab

##### New Member
besides anthonym sorry if you see this topic replicate as "allocate a formula into a variable" . i'm new in mr. excel, and instead of clicking on post reply, i did on new topic. sorry

Replies
2
Views
244
Replies
3
Views
5K
Replies
7
Views
308
Replies
3
Views
2K
Replies
3
Views
258

1,190,827
Messages
5,983,113
Members
439,824
Latest member
nellyc

### 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.

### Which adblocker are you using?

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

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