View Single Post
 
Old 07-16-2014, 07:59 AM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

"ows" is just my own idiosyncratic way of naming a worksheet. Most programmers learn eventually to use more descriptive variable names that just 'i' and 'j', 'x' and 'y'; eventually they start naming things "RetailWorksheet", "MonthlySum" and so forth.

Now, like them I've learned that there's a risk of making a name so cryptic that six months later I've forgotten what it's for and have difficulty understanding my own code. But I still hate my variable names to be too long; it makes for longer statements, more typing and perhaps other sins that I've forgotten just now. So I still make my names a lot shorter than most folks do; I just pack more information into fewer characters.

I long ago gave up using one-character variable names, for reasons that even some experienced programmers will disagree with. So instead of using 'i', 'j', 'k' and so forth, as is traditional for loop indices, I use 'j' plus another character, eg "jr" for rows or "jl" for "list number", whatever strikes my fancy at the time.

For objects I'm currently trying to use 'o' as the starting character, then another character or two to indicate what kind of object. "ows" means "worksheet" to me; "owb" is a workbook, "oc" is a cell, "org" is a range and so on. These names evolve from time to time; in fact until very recently I used "wso", "co" etc.

When I need to distinguish between more than one cell, worksheet or whatever, I add a few letters; owsFm and owsTo, for example, when I'm transferring data from one worksheet to another, or rA and rZ for first and last rows. But when I'm working with just one object of its type at a time, as in this case, I'm content to start a program like this:
Code:
Set owb = ThisWorkbook
Set ows = ActiveSheet
After that I can refer to ows.This and ows.That without thinking much about it.

And by the way all this idiosyncrasy is for my own programs. Whenever I write a program for a client, that someone else may have to maintain next year after I'm gone, then it's all out the window and I must choose names that are likely to mean something more generally, not just in my own personal code.
Reply With Quote