Southanesq
New Member
- Joined
- Mar 29, 2008
- Messages
- 4
I’m a n00b with VBA, so please bear with me.<o
></o
>
<o
> </o
>
I’m running three separate macro(s) that change a selected range of text to either lower, upper or proper (capital letter followed by lower) case.<o
></o
>
<o
> </o
>
The code I’m using x3 is as follows: -<o
></o
>
<o
> </o
>
Sub ChangeCaseLower()<o
></o
>
Dim Rng As Range<o
></o
>
On Error Resume Next<o
></o
>
Err.Clear<o
></o
>
Application.EnableEvents = False<o
></o
>
For Each Rng In Selection.SpecialCells(xlCellTypeConstants, _<o
></o
>
xlTextValues).Cells<o
></o
>
If Err.Number = 0 Then<o
></o
>
' Rng.Value = StrConv(Rng.Text, vbUpperCase)<o
></o
>
' Rng.Value = StrConv(Rng.Text, vbLowerCase)<o
></o
>
' Rng.Value = StrConv(Rng.Text, vbProperCase)<o
></o
>
End If<o
></o
>
Next Rng<o
></o
>
Application.EnableEvents = True<o
></o
>
End Sub<o
></o
>
<o
> </o
>
… With the appropriate Rng.Value for each action.<o
></o
>
<o
> </o
>
I’ve created a UserForm with OptionButton(s) for each change of case.<o
></o
>
<o
> </o
>
If I paste the above code into the OptionButton, the text will change as soon as I run the form and make the selection. However, I’ve created a CommandButton that I want to use to change the text.<o
></o
>
<o
> </o
>
What I want to do is select some cells with text; run the UserForm; select the appropriate option and then press the CommandButton to run the selection I’ve made.<o
></o
>
<o
> </o
>
Any help would be appreciated.
<o
></o
>


<o


I’m running three separate macro(s) that change a selected range of text to either lower, upper or proper (capital letter followed by lower) case.<o


<o


The code I’m using x3 is as follows: -<o


<o


Sub ChangeCaseLower()<o


Dim Rng As Range<o


On Error Resume Next<o


Err.Clear<o


Application.EnableEvents = False<o


For Each Rng In Selection.SpecialCells(xlCellTypeConstants, _<o


xlTextValues).Cells<o


If Err.Number = 0 Then<o


' Rng.Value = StrConv(Rng.Text, vbUpperCase)<o


' Rng.Value = StrConv(Rng.Text, vbLowerCase)<o


' Rng.Value = StrConv(Rng.Text, vbProperCase)<o


End If<o


Next Rng<o


Application.EnableEvents = True<o


End Sub<o


<o


… With the appropriate Rng.Value for each action.<o


<o


I’ve created a UserForm with OptionButton(s) for each change of case.<o


<o


If I paste the above code into the OptionButton, the text will change as soon as I run the form and make the selection. However, I’ve created a CommandButton that I want to use to change the text.<o


<o


What I want to do is select some cells with text; run the UserForm; select the appropriate option and then press the CommandButton to run the selection I’ve made.<o


<o


Any help would be appreciated.


