UCase Column BH in a Sheet

  • Thread starter Thread starter Corey
  • Start date Start date
C

Corey

I have used the Ucase line of code before to format a Textbox or a single cell,
but how can i get it to work on the entirte column BH in a worksheet ?

I tried:
Range("BH:BH").value = Ucase(Range("BH:BH").value)

but i get a type missmatch error


Corey....
 
Sub upper()
Set r = Intersect(Range("BH:BH"), ActiveSheet.UsedRange)
For Each rr In r
rr.Value = UCase(rr.Value)
Next
End Sub
 
There is no "one line" solution. You need to iterate thorugh the constants in
the column and do each on individually. Something like this...

Sub UpperCase()
Dim rngConstants As Range
Dim rng As Range

On Error Resume Next
Set rngConstants = Columns("BH").SpecialCells(xlCellTypeConstants)
On Error GoTo 0

If rngConstants Is Nothing Then
MsgBox "Sorry... Nothing to upper case."
Else
For Each rng In rngConstants
rng.Value = UCase(rng.Value)
Next rng
End If
End Sub
 
Thanks Perfect


Sub upper()
Set r = Intersect(Range("BH:BH"), ActiveSheet.UsedRange)
For Each rr In r
rr.Value = UCase(rr.Value)
Next
End Sub
 
This code works fine so long as there are no formulas in column BH. If there
are it converts the formulas into values that are upper cased. That is
probably an unintended side effect (although that depends on what the OP
wants). Up to you Corey...
 
Thanks Jim.

There will be NO Formula's, ONLY Text values in the Column.

Corey....

This code works fine so long as there are no formulas in column BH. If there
are it converts the formulas into values that are upper cased. That is
probably an unintended side effect (although that depends on what the OP
wants). Up to you Corey...
 
As a general rule I always avoid using procedure that could have unintended
side effects. If I had a nickel for every time that a spreadsheet needed to
be modified in a way that I had not envisioned when it was first created...
that being the case while I am sure there are no formulas in that column now
how about down the road??? Do you want to debug magic disappearing formulas
or use code that will just never overwrite your formulas?

The code that I posted can not overwrite your formulas and it is a bit more
efficient than the code posted by Gary''s Students (no disrespect to Gary''s
code). Normally I would not recommend my code over other code that works (I
have often recommended someone elses code over mine when it was superior)
but in this case I would be inclined to use the code that I posted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Shapes in 2010 1
Seaching an excel sheet 1
Use of UCase 4
Macro to hide column based on value on another sheet 3
using UCase 2
Move row last on change of value 2
Search 14
Fill a column with a formula 1

Back
Top