-
WSdcardno
AskWoody LoungerTell them to change their name.
Microsoft wouldn’t issue a product with a bug – it’s a feature which in this case is telling them that their name is wrong.
-
WSdcardno
AskWoody LoungerGeoff:
You wrote:
“There’s some sample code in Excel which goes:
“for each cell in …”
“When I first came across that, I couldn’t find a type which worked, so I ended up coding…”
I ran into the same thing, although it came from some guy on the comp.apps.spreadsheets ng – he had written a routine to do custom formatting in excel 5. It was quite cool, but he did the same thing: “for each Cell in WorkRange…”
I figured that Cell was a keyword, and couldn’t figure out why I couldn’t re-create his code (at least, not in a way that worked). He was very patient in explaining the problem, and I appreciated that, and he was just a “volunteer” after all.
I agree that it is galling not to have explicit declarations in all the MS help file code examples (and I really hate “myfile,” “myvar,” “mybutton,” etc – they make “mepuke”) and the stuff on the knowledgebase. It doesn’t take much extra time, it is good programming practice, and the whole point is to teach something -sometimes it is useful to know just what sort of value is expected (or allowed) in each variable.
Why doesn’t the lounge have a “recommend this post” feature – your rant deserves a recommendation!
-
WSdcardno
AskWoody LoungerBrett:
John Walkenbach’s EXCELLENT book Microsoft Excel 2000 – Power Progamming with VBA has a discussion of this very topic in chapter 9 (pp 226-237) and walks the reader through the development process for a utility to sort worksheets in alphabetic order.
The eventual program is included in the book, as well as on a companion CD-ROM (as is a slightly improved version). I am reluctant to violate John’s copyright (at least publicly ) but if you pick up a copy in the library there is only about a page of code to re-type, even if you don’t get the CD-ROM. The book is a terrific reference if you are going to be doing any VBA development.
-
WSdcardno
AskWoody LoungerIf you are doing this on a one-time basis, John’s suggestion is th way to go. If you are doing this often, try the code in
http://www.wopr.com/cgi-bin/w3t/showthread…d&sb=5#Post1143%5B/url%5Dbut change the “Upper(Cell.Value)” function to “Application.Proper(Cell.Value)”
This will convert the selected cells from upper- or mixed-case to proper case. That thread is not a bad place to start looking at VBA macros for this sort of thing. If you are having a hard time linking to that post, the whole code would like like this:
****
Sub ConvertToUpper()
On Error GoTo errConvertToUpper
Dim Cell As Range
For Each Cell In Selection
If Not Cell.HasFormula Then Cell.Value = Application.Proper(Cell.Value)
Next Cell
exitConvertToUpper:
Exit Sub
errConvertToUpper:
If Err.Number = 438 Then
MsgBox “You probably don’t have cell(s) selected”, vbExclamation, “Selection Alert”
Resume exitConvertToUpper
End If
MsgBox Err.Number & ” ” & Err.Description
Resume exitConvertToUpper
End Sub****
-
WSdcardno
AskWoody LoungerGood catch, Tom!
I think the code looks pretty good now!
-
WSdcardno
AskWoody LoungerJust like the old carpenter’s rule, “measure twice – cut once” I must remember to read twice, post once!
First, there is no need for the “Rng” variable in my last bit of code – it will work perfectly well by using:
For Each Cell in Selection…
and probably a microsecond faster, too!
Second, Geoff left open the question of how to make the macro available to all workbooks. Create it in your personal macro workbook, and if you are going to use it a lot, assign it to a (new) button on a toolbar. It will always be available to *you*, even if not to other users.
-
WSdcardno
AskWoody LoungerGeoff Whitfield suggested looping through the rows and columns in the selected range and substituting the UCase(text) for text in each cell.
I think the approach is right, but runs into problems if the selected range does not start at A1, or is not a rectangular section of the s/sheet, I would think.
I would suggest:
****
Option ExplicitSub ConvertToUpper()
Dim Rng As Range
Dim Cell As RangeSet Rng = Selection
For Each Cell In Rng
If Not IsNumeric(Cell.Value) Then Cell.Value = UCase$(Cell.Value)
Next CellEnd Sub
****The test for a numeric value is just to avoid overwriting formulas with their value equivalents. Unfortunately I couldn’t find an equivalent “IsString” function, so I had to use the negation of the numeric test – there could be other values that you would want to avoid overwriting.
-
WSdcardno
AskWoody LoungerThanks – works like a charm. I knew I had seen something like that before, but couldn’t recall where (early dementia, I suspect…)
-
WSdcardno
AskWoody LoungerYou might also look at:
http://www.beyondtechnology.com/geeks007.shtml
a site run by Rodney Powell. This particular page discusses the creation of dynamic named ranges, which will expand and contract based on the number of non-blank lines in your s/sheet.
There are come limitations (as always) that may mean it won’t work for you – primarily that the database has to be the only thing on the sheet, and that in order to reference that named range the s/sheet has to be open (although not active).
I am not sure if Access (or was it FoxPro?) would deal properly with such a named range, but it might be worth a try.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Installing Feature Update Windows 11 24H2
by
geekdom
7 hours, 22 minutes ago -
Windows 11 Insider Preview build 27823 released to Canary
by
joep517
7 hours, 46 minutes ago -
Windows 11 Hotpatch
by
Hackmuss
2 hours, 38 minutes ago -
System Guard service error still won’t be fixed
by
Susan Bradley
8 hours, 25 minutes ago -
Operation ForumTroll: APT attack with Google Chrome zero-day exploit chain
by
Alex5723
2 hours, 36 minutes ago -
Troy Hunt of HaveIBeenPwned Phished
by
Lars220
2 hours, 34 minutes ago -
Microsoft Windows security auditing Code 5061
by
mpw
20 hours, 57 minutes ago -
Can’t display images in incoming Outlook 365 emails
by
WScopwriter
4 hours, 33 minutes ago -
Windows 11 Insider Preview Build 26200.5510 early builds of 25H2
by
Alex5723
6 hours, 1 minute ago -
0Patch : Micropatches released for SCF File NTLM Hash Disclosure Vulnerability
by
Alex5723
5 hours, 31 minutes ago -
Select multiple emails and they all open up!
by
CeeJay
1 day, 22 hours ago -
How to remove an update preview
by
Gunny
55 minutes ago -
Third party add ins reminder
by
Susan Bradley
1 day, 1 hour ago -
OTF, which backs Tor, Let’s Encrypt and more, sues to save its funding
by
Nibbled To Death By Ducks
1 day, 15 hours ago -
Updating Windows 10 to Windows 11: 23H2 or 24H2?
by
Still Anonymous
2 days, 2 hours ago -
How can I update “Explorer Patcher”
by
WSplanckster
2 days, 4 hours ago -
Check out the home page for Signal
by
CAS
2 days, 2 hours ago -
Windows 11 and Trial version of MS Office
by
Tex265
2 days, 1 hour ago -
Windows 11 Insider Preview build 26120.3585 (24H2) released to BETA
by
joep517
2 days, 8 hours ago -
Windows 11 Insider Preview build 26200.5510 released to DEV
by
joep517
2 days, 8 hours ago -
Windows 11 Insider Preview Build 26100.3624 (24H2) released to Release Preview
by
joep517
2 days, 8 hours ago -
Limits on User Names
by
CWBillow
2 days, 5 hours ago -
MS-DEFCON 4: Mixed bag for March
by
Susan Bradley
5 hours, 36 minutes ago -
Non Apple Keyboards
by
pmcjr6142
6 hours, 52 minutes ago -
How to delete your 23andMe data – The Verge
by
AJNorth
2 days, 3 hours ago -
7 common myths about Windows 11 (Microsoft AD)
by
EyesOnWindows
2 days, 1 hour ago -
Error updating to Win11 0x8024a205
by
bmeacham
55 minutes ago -
default apps
by
chasfinn
1 day, 8 hours ago -
Will MS Works 4 work in MS Win 11?
by
MileHighFlyer
41 minutes ago -
Adding links to text in Word 2000
by
sgeneris
2 days, 7 hours ago
Recent blog posts
- System Guard service error still won’t be fixed
- Third party add ins reminder
- MS-DEFCON 4: Mixed bag for March
- Classic and Extended Control Panel — no need to say goodbye
- Things you can do in 2025 that you couldn’t do in 2024
- Revisiting Windows 11’s File Explorer
- Planning ahead for migration
- Woody Leonhard (1951–2025)
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.