Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Format Text Cell

Status
Not open for further replies.

cariengon

Technical User
Mar 18, 2002
283
US
I have an excel spreadsheet that is being used as a data entry form. Is there a way to format a cell, so that it is always UPPER case? I know that I can reference the cell and make the new cell Upper, but I want to make sure that it defaults to UPPER without the user having to worry about it.

Thanks!
Carie
 
Carie,

Not without VBA code.

Skip,

[glasses] [red]Be advised:[/red] Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]

Want to get great answers to your Tek-Tips questions? Have a look at FAQ222-2244
 
I was playing around with code and got it to work. My issue now is that the code errors when I protect the worksheet. Why does this happen? Is it the type of function I'm defining?

Here's my code:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim UpperCase

UpperCase = UCase(Cells(33, 2))
Cells(33, 2) = UpperCase

End Sub

Thanks,
Carie

 
If the cell you're trying to change is Locked, then VBA code cannot change the value of the cell if the Sheet is protected.


*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
It's an unlocked cell, but the worksheet is protected. I can enter and delete data. - I just double checked it... Could there be a different reason?

This is the error I get-
Run-time error '1004':
The cell or chart you are trying to change is protected and therefore read-only.
To modify a protected cell or chart, first remove protection using the Unprotect Sheet command.

Hmmm, I get it when there is nothing in the cell. I think I need to add code to allow ISBLANK...

Any suggestions?
Carie




 
Ah Ha!! Got it to work!!

Code:
If IsEmpty(Cells(33, 2) = False) Then
    UpperCase = UCase(Cells(33, 2))
    Cells(33, 2) = UpperCase
End If

Thanks!!! Now I get to tackle validation of blank cells... Maybe another post... :)

Thanks,
Carie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top