Convert to Lower case (not with a function)

T

TAJ Simmons

Excel XP/2002

Is there a quick button I can add to a custom toolbar to convert a selected cell to lower case?

I've searched the customize toolbar menu items but cannot find it. Sure excel has one? (even powerpoint has one!)

Unfortunately a 'function' to convert the data is no use to me this time.

Cheers
TAJ Simmons
microsoft powerpoint mvp

awesome - powerpoint backgrounds,
free powerpoint templates, tutorials, hints and tips etc
http://www.powerpointbackgrounds.com
 
B

Bob Phillips

TAJ,

You will need to create your own.

Below is a sub that you can add to a standard code module in your
Personal.xls and it will convert the selected cells. It has 2 options,
normal click for lower case, shift-click for upper case

You will also need to add the button to a toolbar, this code can do that

Dim oCtl As CommandBarControl

With
Application.CommandBars("Formatting").Controls.Add(Type:=msoControlButton)
.Caption = "Change Case"
.FaceId = 254
.OnAction = "ChangeCase"
End With

This adds a button with a small A (not lower case) and a big A, which seems
appropriate enough.

Here is the case change routine.

Option Explicit

Declare Function GetKeyState Lib "user32" (ByVal fnKey As Long) As Integer

Const vkShift As Integer = &H10

Sub ChangeCase()
Dim cell As Range
For Each cell In Selection
If GetKeyState(vkShift) < 0 Then
cell.Value = UCase(cell.Value)
Else
cell.Value = LCase(cell.Value)
End If
Next cell
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


TAJ Simmons said:
Excel XP/2002

Is there a quick button I can add to a custom toolbar to convert a selected cell to lower case?

I've searched the customize toolbar menu items but cannot find it. Sure
excel has one? (even powerpoint has one!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top