VBA script to change contents of column b in uppercase

rmehta

New Member
Joined
Feb 23, 2011
Messages
7
Hi,

I have a work book with several worksheets within, I would like to turn the contents of Column B within Sheet1-Sheet4 into Uppercase by using a VBA script

Any help would be much appreciated
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi. Try this

Code:
Sub tocaps()
Dim ws As Worksheet, LR As Long, i As Long
For Each ws In Worksheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4"))
    With ws
        LR = .Range("B" & Rows.Count).End(xlUp).Row
        For i = 1 To LR
            .Range("B" & i).Value = UCase(.Range("B" & i).Value)
        Next i
    End With
Next ws
End Sub
 
Upvote 0
Try:
Code:
Sub UpperCase()
Dim i As Long, j As Long
For j = 1 To 4    
    With Sheets(j)
        For i = 1 To .Range("B" & Rows.Count).End(xlUp).Row
            .Range("B" & i) = UCase(.Range("B" & i))
        Next i
    End With
Next j
End Sub
 
Upvote 0
I have always found this code very useful. You select the column or cells you wish to change and an input box appears giving you the choice of Upper, Lower & Proper case.

Code:
Sub CaseSize()
'Changes case size in the selected range of cells
Dim myCase, rng As Range, r As Range
myCase = Application.InputBox("Enter" & vbLf & "1 for Upper Case" & vbLf & _
"2 for Lower Case" & vbLf & "3 for Proper Case", Type:=1)
If (myCase = False) + (Not myCase Like "[1-3]") Then Exit Sub
On Error Resume Next
Set rng = Selection.SpecialCells(2)
On Error GoTo 0
If Not rng Is Nothing Then
For Each r In rng
r.Value = StrConv(r.Value, myCase)
Next
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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