ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet Change Q (https://www.excelbanter.com/excel-programming/422012-worksheet-change-q.html)

Seanie

Worksheet Change Q
 
How can I select multiple ranges within a Change event code? I've
tried below but I hit debug

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count = 1 Then
If Not Intersect(.Cells, Range("J10:J22", "J28:J40",
"J46:J58", "J64:J76", "J82:J94", "J100:J112", "J118:J130")) Is Nothing
Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End If
End With
End Sub

Bob Phillips[_3_]

Worksheet Change Q
 
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const WS_RANGE As String = _
"J10:J22,J28:J40,J46:J58,J64:J76,J82:J94,J100:J112 ,J118:J130"
With Target
If .Count = 1 Then
If Not Intersect(.Cells, Range(WS_RANGE)) Is Nothing Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End If
End With
End Sub


--
__________________________________
HTH

Bob

"Seanie" wrote in message
...
How can I select multiple ranges within a Change event code? I've
tried below but I hit debug

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count = 1 Then
If Not Intersect(.Cells, Range("J10:J22", "J28:J40",
"J46:J58", "J64:J76", "J82:J94", "J100:J112", "J118:J130")) Is Nothing
Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End If
End With
End Sub




Seanie

Worksheet Change Q
 
Thanks Bob



All times are GMT +1. The time now is 11:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com