![]() |
Uppercase in non adjacent columns
I have the following code which will force upper case in column "C":
Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Application.Intersect(Target, Range("C9:C47")) Is Nothing Then ' Target(1).Value = UCase(Target(1).Value) Target(1).Value = StrConv(Target(1).Value, vbUpperCase) End If Application.EnableEvents = True End Sub I would like to adapt this code to work in non-adjacent columns; ie columns "A" and "C". -- tia Jock |
Uppercase in non adjacent columns
replace
Range("C9:C47") with Union(Range("C9:C47"),Range("A9:A47")) -- Gary''s Student - gsnu200729 "Jock" wrote: I have the following code which will force upper case in column "C": Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Application.Intersect(Target, Range("C9:C47")) Is Nothing Then ' Target(1).Value = UCase(Target(1).Value) Target(1).Value = StrConv(Target(1).Value, vbUpperCase) End If Application.EnableEvents = True End Sub I would like to adapt this code to work in non-adjacent columns; ie columns "A" and "C". -- tia Jock |
Uppercase in non adjacent columns
Great stuff, thanks very much!
Jock "Gary''s Student" wrote: replace Range("C9:C47") with Union(Range("C9:C47"),Range("A9:A47")) -- Gary''s Student - gsnu200729 "Jock" wrote: I have the following code which will force upper case in column "C": Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Application.Intersect(Target, Range("C9:C47")) Is Nothing Then ' Target(1).Value = UCase(Target(1).Value) Target(1).Value = StrConv(Target(1).Value, vbUpperCase) End If Application.EnableEvents = True End Sub I would like to adapt this code to work in non-adjacent columns; ie columns "A" and "C". -- tia Jock |
Uppercase in non adjacent columns
Another option:
If Not Application.Intersect(Target, Me.Range("a9:a47,C9:C47")) Is Nothing Then The me keyword refers to the object holding the code--in this case, it's that worksheet. Jock wrote: I have the following code which will force upper case in column "C": Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Not Application.Intersect(Target, Range("C9:C47")) Is Nothing Then ' Target(1).Value = UCase(Target(1).Value) Target(1).Value = StrConv(Target(1).Value, vbUpperCase) End If Application.EnableEvents = True End Sub I would like to adapt this code to work in non-adjacent columns; ie columns "A" and "C". -- tia Jock -- Dave Peterson |
All times are GMT +1. The time now is 05:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com