Hi demuro,
Try this function code in a standard module (open VB Editor, click Insert -> Module, paste the code shown below). In your worksheet, use the formula
=Adjust(C11) (or any other cell reference)
Note that if you change A16 or A29, you'll have to perform a full sheet calculation (CTRL+ALT+SHIFT+F9) for any existing '=Adjust()' formulas to update properly. Also note that because you used ">" and "<" (not ">=" and "<=") there are gaps in the ranges, e.g. 21-85, 88-452.. what happens if the value is 86 or 87? The way it's coded, it will stay 86 or 87. If you need to adjust the code to be all-inclusive of the consecutive ranges, just change the numbers in the Case statements as necessary.
Function Adjust(x)
With Sheets("Ref")
If (.Range("A16").Value = 2 And .Range("A29").Value = 1) Then
Select Case x
Case 21 To 85, 88 To 452, 455 To 806
Adjust = x + 3
Case Else
Adjust = x
End Select
ElseIf (.Range("A16").Value = 3 And .Range("A29").Value <> 1) Then
Select Case x
Case 21 To 85
Adjust = x + 3
Case 88 To 452
Adjust = x + 29
Case 455 To 806
Adjust = x + 136
Case Else
Adjust = x
End Select
ElseIf (.Range("A16").Value = 3 And .Range("A29").Value = 1) Then
Select Case x
Case 21 To 85
Adjust = x + 6
Case 88 To 452
Adjust = x + 132
Case 455 To 806
Adjust = x + 639
Case Else
Adjust = x
End Select
End If
End With
End Function
Bookmarks