VBA Proper Case Question

Shiseiji

Board Regular
Joined
Oct 23, 2009
Messages
214
Office Version
  1. 2019
Platform
  1. Windows
Uh, help please. I've got the simple macro to insert a column, use the Proper function, then copy/paste special over the original column and delete the inserted column. Trying to understand and use the vba examples I find is beyond by basic skill set . . . worst case I'll just use what is working, but I'm trying to learn how to avoid in VBA using an inserted column to run the function.

Lower case I managed to find the code and see how to use it:
Code:
' Find the last row of records for reference
Range("A1").Select
Dim LastRow As Long
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Range("A2:A" & LastRow).Value = LCase(Range("A2:A" & LastRow).Value)

But darned if I can figure out out to convert the code I find that has a user box into code that will simply run on my range . . .

I've tried two different pieces of code, but I can't figure out how to set my range for it to run on my without user input . . .

Code:
Sub ChangeCase()
    Dim Rng As Range
    On Error Resume Next
    R
    Err.Clear
    Application.EnableEvents = False
    For Each Rng In Selection.SpecialCells(xlCellTypeConstants, _
             xlTextValues).Cells
        If Err.Number = 0 Then
           ' Rng.Value = StrConv(Rng.Text, vbUpperCase)
           ' Rng.Value = StrConv(Rng.Text, vbLowerCase)
           ' Rng.Value = StrConv(Rng.Text, vbProperCase)
        End If
    Next Rng
    Application.EnableEvents = True
End Sub

or

Code:
Sub ConvertCase( )
Dim rAcells As Range, rLoopCells As Range
Dim lReply As Long


    'Set variable to needed cells
    If Selection.Cells.Count = 1 Then
        Set rAcells = ActiveSheet.UsedRange
    Else
    Set rAcells = Selection
    End If


    On Error Resume Next 'In case of NO text constants.
    'Set variable to all text constants
    Set rAcells = rAcells.SpecialCells(xlCellTypeConstants, xlTextValues)


    If rAcells Is Nothing Then
    MsgBox "Could not find any text."
    On Error GoTo 0
    Exit Sub
    End If


    lReply = MsgBox("Select 'Yes' for UPPER CASE or 'No' for Proper Case.", _
    vbYesNoCancel, "OzGrid.com")
    If lReply = vbCancel Then Exit Sub


    If lReply = vbYes Then ' Convert to Upper Case
    For Each rLoopCells In rAcells
        rLoopCells = StrConv(rLoopCells, vbUpperCase)
    Next rLoopCells
    Else ' Convert to Proper Case
    For Each rLoopCells In rAcells
        rLoopCells = StrConv(rLoopCells, vbProperCase)
    Next rLoopCells
    End If
End Sub

TIA to anyone able/willing to provide assistance . . .
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Is the three single apostrophes intentional

Code:
        If Err.Number = 0 Then
           ' Rng.Value = StrConv(Rng.Text, vbUpperCase)
           ' Rng.Value = StrConv(Rng.Text, vbLowerCase)
           ' Rng.Value = StrConv(Rng.Text, vbProperCase)
        End If
 
Upvote 0
Yes. It's written to be mulit-function capable. Un rem the desired action. In my case proper case.
 
Upvote 0
Does this macro do what you want...
Code:
[table="width: 500"]
[tr]
	[td]Sub MakeProper()
  Selection = Evaluate(Replace("IF(@="""","""",[B][COLOR="#FF0000"]PROPER[/COLOR][/B](@))", "@", Selection.Address))
End Sub[/td]
[/tr]
[/table]


EDIT NOTE
-----------------------
Yes. It's written to be mulit-function capable. Un rem the desired action. In my case proper case.
In that case, replace the PROPER keyword above with either UPPER or LOWER as needed.
 
Last edited:
Upvote 0
Sir, thank you! I have a colleague who is rather, uh, challenged in several areas "Can you help me turn on spell check in my Outlook?" Due to several factors a file tidy-up I routinely do will now be his project. Thanks for helping me to set him up the best I can to succeed. I'm on to what I hope is my last question on this file, but it will be in a new thread.

Thanks again,

Ron
 
Upvote 0
Can you help me turn on spell check in my Outlook?"
Sorry, I know next to nothing about Outlook. However, I was under the impression that spell-checking was always on in Outlook... considering you asked that question, though, I presume I am wrong about that.
 
Upvote 0
Outlook=> File => Options => Mail scroll to "Compose messages", check the box that says "Always check spelling before sending".
 
Upvote 0
I thought it was a default setting as I don't recall ever having to manually turn it on. But he needed help, I was happy to provide. To me it was like teaching someone to disassemble a bike wheel. From that I can usually determine what their skill set is. Not good, not bad, just what is. Hence my work to try to set him up to succeed as best I can. And I get to learn something too.

Ron
 
Upvote 0
I guess that means you were able to turn Spell Check on for your bicycle challenged friend...
 
Upvote 0

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,039
Latest member
Mbone Mathonsi

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