Hi
If I understand correctly you want to make the formulas to change the references to the active column when a cell is in some specified range is selected.
If that's the case, I would:
- define a name with the reference column
- write the formulas using that name
- use the SelectChange event procedure to change the reference column when a cell in the specified range is activated
From what I understood this would be an example similar to what you need.
Let's say that you have values in columns B:E. In each columns you have values in rows 2:8 and if the sum of those values is less that 100 you want to display the value in A1, else you want to display the value in the corresponding column in Row 10.
For ex., for column B:
=IF(SUM($B$2:$B$8)<100,$A$1,$B$10)
If you activate a cell in, for ex. E2:E8, you'd like the formula to change to:
=IF(SUM($E$2:$E$8)<100,$A$1,$E$10)
My suggestion
1 - Use the SelectChange event procedure to add/change the reference column when a cell in the range B2:E8 is activated:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B2:E8")) Is Nothing Then _
Names.Add "RefCol", Target.EntireColumn
End Sub
2 - change the formula syntax to isolate the reference column. In I5:
=IF(SUM(RefCol $2:$8)<100,$A$1,RefCol $10:$10)
Now try selecting cells in B2:E8. You'll see the value in I5 updating.
This seems a simple solution for your problem, that you can adapt to your needs. Please try.