Hi everyone, I am looking to truncate or group the columns in my VBA. I have looked online, but haven't been successful in implementing into my code. As of now, it looks as follows:
>>> use code - tags <<<
I want to increase the number of columns that this if else statement applies to as well, and this is obviously not very scalable... If anyone knows a better way to write this, or an alternative code, that would be great!
>>> use code - tags <<<
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Select Case Target.Column
Case 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80
If Target.Value = Chr(254) Then
Target.Value = Chr(168)
Cancel = True
ElseIf Target.Value = Chr(168) Then
Target.Value = Chr(254)
Cancel = True
End If
End Select
End Sub
I want to increase the number of columns that this if else statement applies to as well, and this is obviously not very scalable... If anyone knows a better way to write this, or an alternative code, that would be great!
Last edited by a moderator: