Do you have any Excel OCD habits?

(1) I use the VBA prefix whenever I call something in the VBA object library

Colin, I began specifying libraries for objects a couple years back due to the recommendation to do so in Professional Excel Development in order to guard against accidentally getting a Word range object instead of an Excel range if one's code get's ported to Word in an automation setting.
I know you also are active at ExtremeVBTalk where they cover a wide variety of platforms. Is there some type of a danger of code getting ported onto other platforms that you're guarding against?


Whereas I would write:
Code:
Sub foo()
 
    Dim l As Long
 
    l = Cells(Rows.Count, 1).End(xlUp).Row
 
End Sub

I indent the same and yes, I go a bit OCD and fix the indenting if someone posts code that isn't properly indented. Speaking of which, somebody around here posted some code where they aligned the AS's in the DIM. I am trying it out to see if I like it and thus far I kinda do...
Code:
    Rem ___old way___
    Dim strFullNameCurr As String, strFullNameHome As String, _
        strHomePath As String, strCurrPath As String, _
        lngResult As VbMsgBoxResult, i%
 
    '// ___new way___
    Dim strFullNameCurr As String, _
        strFullNameHome As String, _
        strHomePath     As String, _
        strCurrPath     As String, _
        lngResult       As VbMsgBoxResult, _
        i%
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi Greg,

Good to hear from ya, fella.
Is there some type of a danger of code getting ported onto other platforms that you're guarding against?
I think I just formed my own opinion that it's better not to let the compiler guess where it should be looking but, yes, there could be clashes all over the place.

somebody around here posted some code where they aligned the AS's in the DIM. I am trying it out to see if I like and thus far I kinda do...
I think I quite like the "As" alignment but it's not a habit I've picked up yet. I think that's because I tend to group similar data types on the same line, so its value is lost? eg.
Code:
    Dim strFullNameCurr As String, strFullNameHome As String

I'm not keen on using line continuation characters in my declarations, nor type declaration characters, so I guess 'my version' on those other data types would look like this:
Code:
    Dim lngResult As VBA.VbMsgBoxResult
    Dim i As Integer
 
I think I quite like the "As" alignment but it's not a habit I've picked up yet. I think that's because I tend to group similar data types on the same line, so its value is lost? eg.

I also prefer to group like types, what I'm figuring out is that by doing it this way, it makes it a cinch to sort my variables alphabetically. And since I always employ my version of the Simonyi naming conventions, this results in like types getting grouped.

... so I guess 'my version' on those other data types would look like this:
Code:
    Dim lngResult As VBA.VbMsgBoxResult
    Dim i As Integer
Don't you mean?
Code:
    Dim lngResult As VBA.VbMsgBoxResult
    Dim i         As Integer
 
I also prefer to group like types, what I'm figuring out is that by doing it this way, it makes it a cinch to sort my variables alphabetically. And since I always employ my version of the Simonyi naming conventions, this results in like types getting grouped.


Don't you mean?
Code:
    Dim lngResult As VBA.VbMsgBoxResult
    Dim i         As Integer

Oh now THAT is going to be my newest OCD. :eeek:
 
Yeah, I wanna say Nate (coulda been Rory) said sumpin 'bout them gettin' converted to Longs under the hood anyhow. Nonetheless, for a simple counter that's only gonna run a dozen to a couple-hundred iterations, I struggle to break the habit of using the integer type.
 
Don't know if it's OCD or not but I always try and fully reference objects, particualrly when working with multiple objects eg worksheets, workbooks etc.
 
I once tried to use colors that was least likely to run out of ink.
I thin it was OCD, stupid and Greeen all in one really horrible color choices.
 
In a similar vein when the cartidge was running low I used to print in a single colour until the whole cartridge ran out, started with red I think.

Once one colour was finished I changed to the next barely visible colour I could find and so on.

Also bought one of those print refill kits, stained the desk a lovely colour.:)
 

Forum statistics

Threads
1,222,633
Messages
6,167,201
Members
452,104
Latest member
jadethejade

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