Naming Convention

karlitob

New Member
Joined
Jun 24, 2017
Messages
38
Hi all,
Wondering if there is a standard/recommended approach to naming

- Ranges
- Tables
- Graphs
- Worksheets
- Workbooks

etc

I've seen table with 'f' and 'dim' before the table name. Just looking for the better way to go about it.

Thank you
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
.
Dim rng = Ranges
Dim tbl = Tables
Dim graph = Graphs
Dim WS = Worksheets
Dim WB = Workbooks

Is this what you meant ?
 
Upvote 0
Yes that's exactly the sort of thing that I have seen before. I've also seen fImportantTable_2018.

Is there an accepted naming convention for all the above. Hope this question makes sense.
Thanks.
 
Upvote 0
No there isn't an accepted naming convention it is personal choice, the nearest you get that I have seen is Hungarian notation that some swear by.

From Chip Pearsons site...

Coding style is personal to each developer. Everyone has their own prefered methods and idioms. However, by using the guidelines set forth above, you can make your code more robust, faster, and easier to debug and maintain.

Hungarian Notation

Many programmers prefer to use what is called Hungarian Notation (so named because the originator of this method was Hungarian-born Charles Simonyi, first at Xerox PARC and later a top level software architect at Microsoft). In Hungarian Notation, every variable name begins with letters that identify the data type. For example, an Integer type variable would be named intCounter, where the int prefix indicates that this is an Integer type. I have never adopted Hungarian Notation in straight VBA code, but I always use it when naming controls on a form. If you like the idea behind Hungarian Notation, I encourage you to use it. Just be consistent -- once you decide on a set of identifier prefixes, use them consistently in all your code.

Full link
 
Upvote 0
Thank you for that.

You mentioned 'personal choice' - do you have any references or can direct to me to some examples. The link you sent is very interesting but I think its too far beyond my knowledge.

Thanks for your reply. Greatly appreciated.
 
Upvote 0
I did an Excel test once for a job interview. Apparently I was only one that completed the exercises and got them right but I was marked down because I'd used:
Code:
Dim x as Long
and the interviewer claimed x didn't mean anything.

The code was about 6 lines long. It was very very clear what x was doing (iterator for a loop). This is what is meant by difference of opinion over naming conventions.

There is no right answer, there are arguments for and against. Personal choice means your own choice. Read questions on this board and especially answers posted by MVPs (they don't always use properly named variables, ask why and does it really matter?), buy VBA training books, search the internet for "VBA variable names" or "VBA how to name variables"

You can overwhelm yourself with reading but personal choice means find your own style and you can only really do that by practical doing.

Finally, is time better spent wondering what to name a variable or actually have working code that produces output for the user to allow them to complete their task/job?
 
Upvote 0
In coding terms, I'd strongly recommend reading this, not least because it debunks what most people think of as Hungarian Notation (which is not at all the same as what Simonyi intended).

In terms of Excel objects in the UI, I'd agree that consistency is really the only key. If you're building a data model, then it certainly makes sense to distinguish Fact tables from Dimension tables with an identifying prefix to the name, but otherwise I'd say just something to indicate it's a Table rather than a regular defined name would do. I see no real benefit to a naming convention for worksheets or workbooks as it's generally pretty clear what type of object you're referring to, so just a descriptive name should suffice.
 
Upvote 0
Thank you very much for that. I not at the level of coding at all - I didn't know that f represented fact and dim represented dimension. I merely meant if I was using the Name Manager more frequently then what is the best way to name tables etc. I take the point of using clear descriptive names.
Thanks all.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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