ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conver Text to upper case format (https://www.excelbanter.com/excel-programming/372130-conver-text-upper-case-format.html)

harish

Conver Text to upper case format
 
Hi All

I have prepared the code for the worksheet as follows. This code converts
the text to upper case format from any cell of the worksheet. Also it checks
for the specific text as well. This code works fine for all columns and rows
in the worksheet.
But I want to apply this code to column B only instead of whole worksheet.
Means whatever I will type in Column B should be changed to Uppercase and
also check for particular text, for example QUARTZ and SODA LIME.

Any help would be greatly appreciated.
Kind Regards
Harish


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.HasFormula = True Then
Exit Sub
End If
If Target.Cells.Count 1 Then
Exit Sub
End If
Application.EnableEvents = False
Target.Value = UCase(Target.Text)
If Target.Value = "QUARTZ" Or Target.Value = "SODA LIME" Then

Else
MsgBox "Check the Spell"
Target.Select
End If
Application.EnableEvents = True

End Sub

Trevor Shuttleworth

Conver Text to upper case format
 
Add

If Intersect(Target, Columns("B")) Is Nothing Then Exit Sub

at the beginning of the routine

Regards

Trevor


"Harish" wrote in message
...
Hi All

I have prepared the code for the worksheet as follows. This code converts
the text to upper case format from any cell of the worksheet. Also it
checks
for the specific text as well. This code works fine for all columns and
rows
in the worksheet.
But I want to apply this code to column B only instead of whole worksheet.
Means whatever I will type in Column B should be changed to Uppercase and
also check for particular text, for example QUARTZ and SODA LIME.

Any help would be greatly appreciated.
Kind Regards
Harish


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.HasFormula = True Then
Exit Sub
End If
If Target.Cells.Count 1 Then
Exit Sub
End If
Application.EnableEvents = False
Target.Value = UCase(Target.Text)
If Target.Value = "QUARTZ" Or Target.Value = "SODA LIME" Then

Else
MsgBox "Check the Spell"
Target.Select
End If
Application.EnableEvents = True

End Sub





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

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