ed.ayers315
Board Regular
- Joined
- Dec 14, 2009
- Messages
- 166
Hi Folks,
I have a macro to highlight the row and column that the cursor is in.
3 Problems I have:
1) I needed a way to turn it off; so added the code marked #2 to each sheet so a doulble click would turn the highlighting off. The trouble with this is that it places the cell in edit mode that was doulble clicked. Not what I need.
2) Would there be code to ignore merged cells; in columns and rows?
3) I want to turn of the highlights before printing. Without the current cell being put in edit mode.
Code #1 This is on the Workbook
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim i As Integer
Cells.Interior.ColorIndex = x1none
For i = 1 To Target.Row
Cells(i, Target.Column).Interior.ColorIndex = 6
Next
For i = 1 To Target.Column
Cells(Target.Row, i).Interior.ColorIndex = 6
Next
End Sub
This is on the worksheet
Code #2
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim i As Integer
Cells.Interior.ColorIndex = x1none
For i = 1 To Target.Row
Cells(i, Target.Column).Interior.ColorIndex = x1none
Next
For i = 1 To Target.Column
Cells(Target.Row, i).Interior.ColorIndex = x1none
Next
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
End Sub
I have a macro to highlight the row and column that the cursor is in.
3 Problems I have:
1) I needed a way to turn it off; so added the code marked #2 to each sheet so a doulble click would turn the highlighting off. The trouble with this is that it places the cell in edit mode that was doulble clicked. Not what I need.
2) Would there be code to ignore merged cells; in columns and rows?
3) I want to turn of the highlights before printing. Without the current cell being put in edit mode.
Code #1 This is on the Workbook
Code:
Dim i As Integer
Cells.Interior.ColorIndex = x1none
For i = 1 To Target.Row
Cells(i, Target.Column).Interior.ColorIndex = 6
Next
For i = 1 To Target.Column
Cells(Target.Row, i).Interior.ColorIndex = 6
Next
End Sub
Code:
This is on the worksheet
Code #2
Code:
Dim i As Integer
Cells.Interior.ColorIndex = x1none
For i = 1 To Target.Row
Cells(i, Target.Column).Interior.ColorIndex = x1none
Next
For i = 1 To Target.Column
Cells(Target.Row, i).Interior.ColorIndex = x1none
Next
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
End Sub
Code: