![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
I want what to make sure the text in column E is caps how can this be done? Thanks
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Houston, TX
Posts: 303
|
Check help for UPPER
|
|
|
|
|
|
#3 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
With a function:
=upper(e1) Cheers, Nate |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
If you want to use data validation, choose custom and
=EXACT(A1,UPPER(A1)) for cell A1. Note the major validation limitations, such as these will not keep a user from pasting in lower case letters. |
|
|
|
|
|
#5 |
|
Guest
Posts: n/a
|
how about in VBA?
|
|
|
|
#6 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
To test:
myrng = Range("e9") If myrng = UCase(myrng) Then 'Task if Upper case Else: 'task if lower case 'i.e., range("e9") = Ucase(myrng) End If Cheers, Nate |
|
|
|
|
|
#7 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Or you can force the issue without testing:
e.g., Sub Uppers() Range("e1:e65536").Select For Each cell In Selection myrng = ActiveCell ActiveCell = UCase(myrng) ActiveCell.Offset(1, 0).Select Next End Sub Cheers, Nate |
|
|
|
|
|
#8 | |
|
Join Date: Feb 2002
Posts: 39
|
Quote:
The above will convert any cells that contain formulas to values only. To convert non-formula cells only to Upper :- Sub Uppers() Dim rng As Range, cell As Range Set rng = Intersect(ActiveSheet.UsedRange, Columns(5)) For Each cell In rng If cell.HasFormula = False Then cell.Value = UCase(cell.Value) End If Next cell End Sub The following will convert cells to Upper and retain any formulas if the text being returned by the formula is contained as part of the formula(eg, ="a"), but will not convert to Upper if the result is obtained indirectly (eg, by a LOOKUP formula) :- Sub Uppers() Dim rng As Range, cell As Range Set rng = Intersect(ActiveSheet.UsedRange, Columns(5)) For Each cell In rng If cell.Formula <> "" Then cell.Formula = Format(cell.Formula, ">") End If Next cell End Sub |
|
|
|
|
|
|
#9 |
|
Join Date: Feb 2002
Posts: 39
|
Or if you want to automate it upon entries being made in column E :-
Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range, cell As Range If Not Intersect(Selection, Columns(5)) Is Nothing Then For Each cell In Intersect(Selection, Columns(5)) If cell.Formula <> "" Then cell.Formula = Format(cell.Formula, ">") End If Next cell End If End Sub |
|
|
|
|
|
#10 |
|
Join Date: Feb 2002
Posts: 39
|
Correction. Better make that :-
Private Sub Worksheet_Change(ByVal Target As Range) Dim rng1 As Range, rng2 As Range, cell As Range Application.EnableEvents = False If Not Intersect(Selection, Columns(5)) Is Nothing Then Set rng1 = Intersect(Selection, Columns(5)) Set rng2 = Intersect(ActiveSheet.UsedRange, rng1) For Each cell In rng2 If cell.Formula <> "" Then cell.Formula = Format(cell.Formula, ">") End If Next cell End If Application.EnableEvents = True End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|