0
votes

I'm having a problem when a user selects a entire column in the worksheet the code is attempting to evaluate changes to each cell. How can I write a simple if statement that if the entire column or columns are selected to exit the sub?

I believe my issue lies with this line For Each cell In target.Cells.

After this line several things occur so I was thinking I could embed this in a line such as:

If selection = .Columns("A:A").EntireColumn.Select Then Exit Sub.

How do i define the ".Columns("A:A")" to be any column selection?

1
Please add the code your are trying in the questionuser3271518
Selecting a column doesn't trigger the Worksheet_Change event... How does this come to be?John Bustos
(Untested) Could you do something like If Selection.Cells(1, 1).Row = 1 And Selection(Selection.Count).Row = 1048576 Then?BobbitWormJoe

1 Answers

0
votes
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

   If Application.Selection.Rows.Count = Application.Selection.EntireColumn.Rows.Count Then MsgBox ("entire column") 'do something here

End Sub

Obviously, this isn't the full code, you need to incorporate this into your existing macro.