View Single Post
  #7   Report Post  
David McRitchie
 
Posts: n/a
Default

This thread is perhaps good examples of incomplete macros.
I think it is very important that someone starting out with macros
be offered good examples rather than something that just
works correctly.

1) Not protecting formulas was the big mistake, it destroys
the structure and usability of the worksheet. Though usually
recoverable if know what you did and can replace the formulas.
2) A definite range in a macro means you have to change
the range each time you run a macro, or that your data will
eventually exceed your range. Generally this is
not a good idea. Not even as an example, because it is
not something that can be used anytime, anywhere (not generic).
3) Turning off screen updating makes it so the screen doesn't have
to keep on refreshing will speed up the process, but
turning off calculation should have also been included.
BUT also provide for errors, because YOU MUST turn
calculation back on if things fail or you can mess yourself up.
4) Selection itself is NOT good enough, If I were to select
an entire column the revised macro would take 3 minutes (per column)
on my slow machine (600mHz). Reducing the cells to be
changed based on whether they are constants would
speed things up to hundredths of a second for most sheets
which usually don't have much data.
5) A worksheet solution was also suggested and it is not good
in this case because it is a one time thing that is wanted, and
the clean up to remove the extra column is a LOT of work.

For a macro that changes a selection to upper case see
Proper, and other Text changes -- Use of SpecialCells
change to upper case
http://www.mvps.org/dmcritchie/excel/proper.htm#upper
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Gord Dibben" <gorddibbATshawDOTca wrote in message ...
Once again Julie......

FYI and hopefully a tip. Are you aware with that code, if there are any
formulas in the range they will be wiped out leaving values only?

I realize OP mentioned text only but on the odd chance that some of the text
seen may be the results of formulas the following code would not affect
formulas. It will however, change case of any text returned by a formula as
well as in text-only cells.

Just select a range and run code.

Sub Upper_Case()
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Selection
cell.Formula = UCase(cell.Formula)
Next
Application.ScreenUpdating = True
End Sub


Gord Dibben Excel MVP

On Fri, 29 Apr 2005 00:38:46 +0800, "JulieD"
wrote:

Hi

will the following code do what you want (always test code on a copy of the
workbook first!)

sub changetoupper()
for each c in Range("A1:A100")
c.value = UCASE(c.value)
next
end sub