Replace RegEx smaller case with upper case

od33n

New Member
Joined
Feb 12, 2013
Messages
8
Hi all,

Is there any solution to do this task? I have been searching for solution, but i did not found it.

I am using this code for replaces. But dont know, how to say the script, that $2 i want to replace with small case

For example
elefant 1234AB to elefant 1234ab

I know i can do it also with replace without regex, but there is too much words what i need to replace

Thank you for helping me...

select_all_icon.jpg
page_white_copy.png


<code style="margin: 0px; padding: 0px; font-style: inherit;"> Dim r As Range Dim Univers0 As Object 'elefant 1234AB to elefant 1234ab animal.Pattern = "^(elefant \d{1,4})(A-Z){1,2}" For Each r In Range("A2", Range("A" & Rows.Count).End(xlUp)) If animal.test(r.Value) Then r(, 1).Value = animal.Replace(r.Value, "$1$2") End If NextEnd Sub</code></pre>
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
The "Lower" worksheet function should work. You could also use the "LCase" function if you insist on using VBA.

Gary
 
Upvote 0
Code:
Public Sub Test()

Dim r As Range

For Each r In Range("A2", Range("A" & Rows.Count).End(xlUp))
    r.Value = LCase(r.Value)
Next

End Sub

or using a formula:

In cell A1: "TEXT TO BE CHANGED TO LOWER CASE"
Formula in cell B1: =LOWER(A1)

Fill B1 down to end of column A

Hope this helps.

Gary
 
Upvote 0
Hmmm,
this seems very good, but i am quite noobie in VBA so I would like to ask you also if i can combine this LCase with regEx as i have typed above.

The thing is, that in A column is not all strings needed to be lowered. So only those, that have 1 to 4 digits before for example (as code above)

Thank you very much.

Code:
Public Sub Test()

Dim r As Range

For Each r In Range("A2", Range("A" & Rows.Count).End(xlUp))
    r.Value = LCase(r.Value)
Next

End Sub

or using a formula:

In cell A1: "TEXT TO BE CHANGED TO LOWER CASE"
Formula in cell B1: =LOWER(A1)

Fill B1 down to end of column A

Hope this helps.

Gary
 
Upvote 0
Maybe something like this:

Code:
Public Sub Test()

Dim r As Range

For Each r In Range("A2", Range("A" & Rows.Count).End(xlUp))
    If Val(r) <> 0 Then
        r.Value = LCase(r.Value)
    End If
Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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