# 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

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Replies
0
Views
225
Replies
20
Views
843
Replies
2
Views
65
Replies
14
Views
385
Replies
6
Views
413

1,214,769
Messages
6,121,436
Members
449,032
Latest member
egspen2

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