Need VBA Help Making Columns A,B,E,J Uppercase in Specific Sheet

bepedicino

Board Regular
Joined
Sep 29, 2014
Messages
73
Could someone please help me by providing VBA code that will make columns A,B,E,J in a specific sheet uppercase?
 
The VBA function for that is UCASE.
Is everything in these columns hard-coded, or are there any formulas in these columns?
 
Upvote 0
I enter the data manually in columns A and B Just in case you need to know columns E and J contain the validation list functions but no formulas.
 
Upvote 0
Try giving this a whirl:
Code:
Sub MakeUpperCase()

    Dim myCols As Variant
    Dim i As Integer
    Dim myLastRow As Long
    Dim myRow As Long
    
'   Specify columns to apply to
    myCols = Array("A", "B", "E", "J")
    
    Application.ScreenUpdating = False
    
'   Loop through columns
    For i = LBound(myCols) To UBound(myCols)
'       Find last row of that column
        myLastRow = Cells(Rows.Count, myCols(i)).End(xlUp).Row
'       Loop through all rows in that column (down to last row with data)
        For myRow = 1 To myLastRow
'           Make entries upper case
            Cells(myRow, myCols(i)) = UCase(Cells(myRow, myCols(i)))
        Next myRow
    Next i
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Thank you very much, but no luck. Maybe it would be helpful if I send you my macro prior adding what you gave me. I am trying to fit it in right after Columns("I").Delete.

Sub ReadyForUpload()


Const MyTarget = "#N/A" ' <-- change to suit

Dim Rng As Range, DelCol As New Collection, x
Dim i As Long, j As Long, k As Long

' Calc last row number
j = Cells.SpecialCells(xlCellTypeLastCell).Row 'can be: j = Range("C" & Rows.Count).End(xlUp).Row

' Collect rows range with MyTarget
For i = 1 To j
If WorksheetFunction.CountIf(Rows(i), MyTarget) > 0 Then
k = k + 1
If k = 1 Then
Set Rng = Rows(i)
Else
Set Rng = Union(Rng, Rows(i))
If k >= 100 Then
DelCol.Add Rng
k = 0
End If
End If
End If
Next
If k > 0 Then DelCol.Add Rng

' Turn off screen updating and events
Application.ScreenUpdating = False
Application.EnableEvents = False

' Delete rows with MyTarget
For Each x In DelCol
x.Delete
Next

' Update UsedRange
With ActiveSheet.UsedRange: End With

' Restore screen updating and events
Application.ScreenUpdating = True
Application.EnableEvents = True


With Application
.Calculate
.ScreenUpdating = False
.Calculation = xlCalculationManual
.DisplayAlerts = False
End With

With ActiveSheet
.Columns.Hidden = False
.Rows.Hidden = False
.UsedRange.Value = .UsedRange.Value
End With

For Each Worksheet In ThisWorkbook.Worksheets
If Worksheet.Name = ActiveSheet.Name Then
Else
Worksheet.Delete
End If
Next Worksheet

With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.DisplayAlerts = True
End With

Columns("U").NumberFormat = "@"

Range("A:E").Replace Chr(10), ""

Range("A:E").Replace Chr(13), ""

Columns("F").Delete

Columns("I").Delete

Const Ffold As String = "\\WS0113\WLDepts$\Administration\Trade Compliance\IT\Integration Point\Daily - Product Classification Upload\" 'change as required
Dim Fname As String

Fname = "Product Classification Upload"
Fname = Fname & " - " & Format(Date, "yyyymmdd") & ".xlsx"

Application.DisplayAlerts = False

ActiveWorkbook.SaveAs _
Filename:=Ffold & Application.PathSeparator & Fname, _
FileFormat:=xlOpenXMLWorkbook

Application.DisplayAlerts = True

End Sub
 
Upvote 0
What happens if you try running it as a Standalone macro on a single sheet (forget this other macro you have for a moment).
Does that work?
 
Upvote 0

Forum statistics

Threads
1,226,883
Messages
6,193,488
Members
453,803
Latest member
hbvba

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