excel 2016 VBA using variable to replace formula criteria

RCBricker

Well-known Member
Joined
Feb 4, 2003
Messages
1,560
hello everyone.

I am trying to build a formula for insertion into a cell. this is an R1C1 formula. It will have variable amount of cells added into depending on the data set.

So here we go.

Code:
                    strCAL = "="
                    
                    int1000 = rngHEAD.Find("1000").Row
                    If Not int1000 = "" Then
                        int1000 = int1000 - cell.Row
                        strCAL = strCAL & "+R[" & int1000 & "]C"
                    End If

                    ws.Cells(cell.Row, cell.Offset(, 3)).FormulaR1C1 = strCAL

is there a way to do this? other line items need to calculate as many as six cells but not all six cells will be available for each report. the problem is there is a possibility that the cells will have other line items between them so that the R1C1 needs to be dynamic.

So not all criteria is present at all times AND criteria is not always in the same spot. Hence the reason to try and build the body of the formula using a variable and then referencing said variable in the formula.

Any suggestions?

thanks,
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,542
Messages
5,832,346
Members
430,128
Latest member
ojl987

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
Top