Command Button To Change Active Cell in Proper Case

Stonesteel

Board Regular
Joined
Apr 27, 2010
Messages
81
Greetings!

I really appreciate your help in advance... I am working on a database with hundreds of entries on it, there is a column that has names on it. now i need a command button that when i click, the active cell will be changed in a Proper Case format, can you help me giving a "simple" code that will make it? :biggrin:
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Why a Command Button? I suggest a Double Click
Code:
Private Sub WorkSheet_BeforeDoubleClick(ByVal Target as Range, Cancel as Boolean)
If Target.Column <> 1 Then Exit Sub
Target =Proper(Target)
End Sub
The code is similar for ActiveCell (Although that's usually avoided)
Code:
ActiveCell = Proper(ActiveCell)

lenze
 
Upvote 0
Hi Stonesteel,

Try:

Code:
ActiveCell.Value = StrConv(ActiveCell.Value, vbProperCase)

HTH

Robert
 
Upvote 0
I prefer to use command button because this is more manageable than any other option (for me),, also I am using command button for other operation since i started this work.

by the way, can you help me giving code that i need? thanks much for your help.
 
Upvote 0
So you would rather move the mouse to a cell and select it. Then move the mouse to the button and click it. Then move to another cell and repeat the process for each cell. Wouldn't a DoubleClick make more sense and be more efficent? Anyway, I did give you the code to place in the Command Button's module. Or, you can loop through your column and do them all at once.
Code:
Sub MakeProper()
Dim cl as Range
For Each cl in Range("$A$2:$A" & Cells(Row.Count,"A")End(xlUp).Row)
cl =Proper(cl)
Next cl
End Sub
lenze
 
Upvote 0
hayyzzz, i must admit that i am not very good when it comes to visual basics,..

by the way your last post seems to have an error, when i am inserting this to a module, it appears this way..

Code:
Sub MakeProper()
Dim cl as Range
[COLOR=red]For Each cl in Range("$A$2:$A" & Cells(Row.Count,"A")End(xlUp).Row)[/COLOR]
cl =Proper(cl)
Next cl
End Sub

i am very sorry, please have patience...:(
 
Upvote 0
This one seems operational,

ActiveCell.Value = StrConv(ActiveCell.Value, vbProperCase)

but how about making it the whole column, the column where entries are in Column I.
 
Upvote 0
Hi Stonesteel,

Try this where it converts each entry from I2 down to the last row found in column I to proper case for the active tab:

Code:
Sub Macro1()

    Dim lngLastRow As Long
    Dim rngCell As Range, _
        rngData As Range
    
    lngLastRow = Cells(Rows.Count, "I").End(xlUp).Row
    Set rngData = Range("I2:I" & lngLastRow)
    
    Application.ScreenUpdating = False
    
    For Each rngCell In rngData
        rngCell.Value = StrConv(rngCell.Value, vbProperCase)
    Next rngCell
    
    Application.ScreenUpdating = True
    
End Sub

HTH

Robert
 
Upvote 0
Sorry!! Typo. Shoulde be
Rich (BB code):
For Each cl in Range("$A$2:$A" & Cells(Rows.Count,"A")End(xlUp).Row

lenze
 
Upvote 0
Thank you very much guys for your help, both of your codes contributed a big help in my work. Thanks again. :biggrin::biggrin::biggrin:
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top