Mousehunter
New Member
- Joined
- May 6, 2008
- Messages
- 25
- Office Version
- 2013
- 2010
- Platform
- Windows
Hello there!
I am trying to connect the dots here between calculation event, selection change event and update of conditional formatting...
I know that if I want to highlight the column and the row of a selected cell, I must select a range and conditionally format it with this rule: =+OR(CELL("col")=COLUMN();CELL("row")=ROW()).
I also know that if I do not force recalculation of the sheet, I will not get the desired event because the formula in the rule of conditional formatting will not recalculate and the formatting will not be applied to the row and column of the newly selected cell.
This means that I must force recalculation with every selection change event. But by doing so, I also know that I empty the clipboard and I am restricting myself from pasting a copied or cut range. To enable me to paste a cut or copied range, I must block the recalculation event if the clipboard is not empty. I do this with the following code.
But by doing this I am blocking the recalculation which is a prerequisite for the conditional formatting to work. A vicius cirlce, an infinite logic loop.
A vicius cirlce, an infinite logic loop!
But it seems to work! How can this be? I have blocked recalculation and after pasting the clipboard is still not empty. How can this be working?
Any ideas?
I am trying to connect the dots here between calculation event, selection change event and update of conditional formatting...
I know that if I want to highlight the column and the row of a selected cell, I must select a range and conditionally format it with this rule: =+OR(CELL("col")=COLUMN();CELL("row")=ROW()).
I also know that if I do not force recalculation of the sheet, I will not get the desired event because the formula in the rule of conditional formatting will not recalculate and the formatting will not be applied to the row and column of the newly selected cell.
This means that I must force recalculation with every selection change event. But by doing so, I also know that I empty the clipboard and I am restricting myself from pasting a copied or cut range. To enable me to paste a cut or copied range, I must block the recalculation event if the clipboard is not empty. I do this with the following code.
But by doing this I am blocking the recalculation which is a prerequisite for the conditional formatting to work. A vicius cirlce, an infinite logic loop.
A vicius cirlce, an infinite logic loop!
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.CutCopyMode = 0 Then
Target.Calculate ' Application.Calculate
End If
End Sub
But it seems to work! How can this be? I have blocked recalculation and after pasting the clipboard is still not empty. How can this be working?
Any ideas?