corentint
New Member
- Joined
- Jan 31, 2022
- Messages
- 32
- Office Version
- 365
- Platform
- Windows
I have acquired a chess Excel Worksheet that works fine. However I was interested in the VBA programming behind the worsksheets (I am proficient, yet not expert in VBA Excel).
I came accross this peculiar syntax, which works:
[FEN_New] = sFENiniEN
Where FEN_NEW is actually a named range in the Excell spreadsheet
And sFENiniEN is actually a "Public Const sFENiniEN As String" in other words a VBA value only
I modified [FEN_New] to Range("FEN_New") and the code run without a hitch, of course.
Then I went to one of my own program in another completely independant workbook, and replace a few Range("namedrange") with this syntax [Namedrange], and ran the code, without any problems!
First time I see a usage of [ and of ].
Now which is easier to code, particularly if you use only named range in your worksheets:
[FEN_New] = sFENiniEN
Range("FEN_New")= sFENiniEN
?
I also tested the reverse (xFENiniEN = [FEN_New].value), works fine (used xFENiniEN instead as a variable, xFENiniEN being a constant, value cannot be changed).
My simple questions:
I came accross this peculiar syntax, which works:
[FEN_New] = sFENiniEN
Where FEN_NEW is actually a named range in the Excell spreadsheet
And sFENiniEN is actually a "Public Const sFENiniEN As String" in other words a VBA value only
I modified [FEN_New] to Range("FEN_New") and the code run without a hitch, of course.
Then I went to one of my own program in another completely independant workbook, and replace a few Range("namedrange") with this syntax [Namedrange], and ran the code, without any problems!
First time I see a usage of [ and of ].
Now which is easier to code, particularly if you use only named range in your worksheets:
[FEN_New] = sFENiniEN
Range("FEN_New")= sFENiniEN
?
I also tested the reverse (xFENiniEN = [FEN_New].value), works fine (used xFENiniEN instead as a variable, xFENiniEN being a constant, value cannot be changed).
My simple questions:
- Is this shortcut syntax well known? (I searched high and low on the web, nothing found; I also have books about VBA for Excel, never saw this; I do know about @ # $ % to dim variables)
- If it is known, is it advisable to use it? In other words, no short comings?