I have a large sheet - in column 3 I have a cell value that toggle between False/True - This indicates if that row is ignored or not when I do calculations. However I want to be able to select mutiple rows - then toggle the value(s) in column 3 for all rows selected. I left in the other part of this event - as Row= 4 - sorts the data by whatever column clicked - so I do a sort - then make a selection of a bunch of rows to "Toggle" - sort again - make more "Toggle" selections and so on.
The code cannot reside in the sheet section as this is eventually an add-in
The code in red is what I am lookin to change(optimize)
ThisWorkBook
PS I really wanted column 3 to be a checkbox - but after having inserted Checkboxes for multiple thousand rows - Excel starts to crawl - so I gave up on that idea.
The code cannot reside in the sheet section as this is eventually an add-in
The code in red is what I am lookin to change(optimize)
ThisWorkBook
Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Select Case Target.Row
Case 1
If Target.Column = 4 Then Call ComboBoxX_Click
Case 4
If IsEmpty(Target.Value) Then Exit Sub
Static MySortType As Integer
If MySortType = 0 Then
MySortType = xlAscending
ElseIf MySortType = xlAscending Then
MySortType = xlDescending
ElseIf MySortType = xlDescending Then
MySortType = xlAscending
End If
Target.CurrentRegion.Offset(1).Sort key1:=Target, order1:=MySortType, Header:=xlYes
End Select
[COLOR=red]Select Case Target.Column
Case 3
If Target.Row >= 5 And ActiveSheet.Cells(4, Target.Column).Value = "Ignore" Then
With ActiveCell
If .Value = "True" Then
.Value = "False"
.Interior.Color = &HFFFFFF 'White
Else
.Value = "True"
.Interior.Color = &H80FFFF 'Yellow
End If
End With
End If
End Select
[/COLOR]End Sub
PS I really wanted column 3 to be a checkbox - but after having inserted Checkboxes for multiple thousand rows - Excel starts to crawl - so I gave up on that idea.