Results 1 to 12 of 12
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel VBA Naming Conventions... (2000 SR-1)

    Does anyone have a list (or link to a list) of the proper standard naming conventions for Excel VBA programming? TIA

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    Here's the Reddick conventions.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    Thanks John... <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

    I appreciate that, but that list I know... I'm looking for generally followed naming conventions specifically for Excel Objects... such as prefixes to use when declaring Excel Objects like worksheets and ranges, etc...... For example "Dim someName as Workbook" ... Should that object variable name be given a certain prefix? ....and if so, is there a list of such prefixes?

  4. #4
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Missouri, USA
    Posts
    103
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    I don't have it with me right now, but I think that John Walkenbach does in his book MS Excel Power Programming with VBA. I can check tomorrow.

  5. #5
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    Thanks!... I can wait... (I've been wondering this for agessssss...) <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    He suggests prefixing a lower case:
    b for Boolean
    i for integer
    l for Long
    s for Single
    d for Double
    c for Currency
    dt for Date/Time
    str for String
    obj for Object
    v for Variant
    u for User-defined

    His XL2000 book does not really list anything for the XL objects (as was your original question). He is also not consistent in his use of the conventions. He suggests declaring the variables, but frequently does not do this in his code.

    Steve

  7. #7
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    Hmmm... Well thanks anyway Steve... <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    I personally use...
    bln for Boolean
    int for Integer
    lng for Long
    sng for Single
    dbl for Double
    etc...
    I think that's pretty standard...

    I guess it doesn't really matter as long as the prefixes are intuitive and consistent... I was just curious because I'm trying to get better at Excel VBA, I don't have a book (yet), Excel 2000 Help SUCKS (half the time it doesn't even show the declarations in the examples...), and I know there are experts on here whose opinions I trust and respect... Every time I declare a worksheet or a range or whatever, I think... "Now what should I be using here... sht for Worksheet... wrksht.... or what??" ... I'm just particular (or should I say peculiar) like that... <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    I just make up my own prefixes:

    <table border=1><td>Object</td><td>Prefix</td><td>Chart</td><td>cht</td><td>Dialog</td><td>dlg</td><td>PivotTable</td><td>pvt</td><td>QueryTable</td><td>qtb</td><td>Range</td><td>rng</td><td>Series</td><td>ser</td><td>Shape</td><td>shp</td><td>Sheet</td><td>sht</td><td>Workbook</td><td>wbk</td><td>Worksheet</td><td>wsh</td></table>
    But I reserve the right to deviate from this. Depends on my mood, the phase of the moon, etc. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  9. #9
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    Here are 2 KB articles from Microsoft:

    http://support.microsoft.com/default.aspx?...kb;en-us;110264
    http://support.microsoft.com/default.aspx?...kb;en-us;173738

    Though these don't answer your question either.

    I agree with Hans. I try to use particular ones, though i don't hold myself to them (I am not anal enough to stop myself from being sloppy)
    Steve

  10. #10
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    Thanks Hans... This is a great reference for me as I get used to it... <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  11. #11
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> Well I TRY to keep myself from being sloppy... not that it always works...
    Thanks for the articles Steve!

  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel VBA Naming Conventions... (2000 SR-1)

    I try to use prefixes as much as I can force myself to <img src=/S/smile.gif border=0 alt=smile width=15 height=15>.

    I started off with single letter ones and now mix single and three letter prefixes.

    What you use is not very important, as long as you try to stick to it.

    For XL objects I tend to be lazy, I just use o, as in
    Dim oRange as Range
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •