Posted by: NC | September 25, 2008

Applying case formatting in Excel

A question from Askville:

Excel question – is there any way to apply a function in place?

A couple of examples – I have a cell that is in lower case and I want it to be upper case. Can I apply that function to the cell? or do I have to create another column, apply the function there, copy and paste special:values to get the cell in the format I want? Or taking a cell with a name in it that isn’t “proper” – can I do that against the existing cell without having to go through all those other convulsions?

You can, but you’ll need to write a macro to do it. Something along these lines:

Sub ApplyUpper()
  For Each Cell In Selection
    Cell.Value = UCase(Cell.Value)
  Next Cell
End Sub

Sub ApplyProper()
  For Each Cell In Selection
    Cell.Value = StrConv(Cell.Value, vbProperCase)
  Next Cell
End Sub
About these ads

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: