# Convert Excel formula to VBA - keeping relative and absolute references

#### fluru

##### New Member
Dear all!

I am trying to reduce the processing time of a worksheet that contains the following formula.

The constants need to remain constant but the rest will have to reflect the position in the worksheet e.g. as it would if the formula were copied across columns.

=IF(AND(\$K10>=X\$4,\$K10<Y\$4),\$K\$6,IF(X\$3="XSD","Xmas",IF(AND(\$L10>=X\$4,\$L10<Y\$4),\$L\$6,IF(AND(\$M10>=X\$4,\$M10<Y\$4),\$M\$6,IF(AND(\$N10>=X\$4,\$N10<Y\$4),\$N\$6,IF(AND(\$O10>=X\$4,\$O10<Y\$4),\$O\$6,IF(AND(\$P10>=X\$4,\$P10<Y\$4),\$P\$6,IF(AND(\$S10>=X\$4,\$S10<Y\$4),\$S\$6,IF(AND(\$R10>=X\$4,\$R10<Y\$4),\$R\$6,IF(AND(\$Q10>=X\$4,\$Q10<Y\$4),\$Q\$6,IF(OR(Y10=\$K\$6,Y10=\$L\$6,Y10=\$M\$6,Y10=\$N\$6,Y10=\$O\$6,Y10=\$P\$6),SUM(MAX(Y10:AE10)+1),IF(AND(Y10>0,Y10<10),SUM(MAX(Y10:AE10)+1),IF(Y10="Aircon","",IF(Y10="","",IF(AND(Y10="Xmas",Z10="Xmas",OR(AA10="",AA10="Aircon")),"",SUM(MAX(Y10:AE10)+1))))))))))))))))

Any assistance in converting this into a VBA function would be appreciated ### Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Replies
6
Views
225
Replies
7
Views
223
Replies
4
Views
248
Replies
0
Views
221
Replies
5
Views
282 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

1,163,516
Messages
5,832,205
Members
430,115
Latest member
RainerJonker ### 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