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:
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 . . .
or
TIA to anyone able/willing to provide assistance . . .
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 . . .