+ Reply to Thread
Results 1 to 5 of 5

understanding syntax

  1. #1
    Registered User
    Join Date
    06-19-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    understanding syntax

    Programming group:

    I am a beginner in vba programming and and having a problem understanding the syntax used. For example in a duplicate-finding macro I see the syntax "xlShiftUp" and don't know what the xl means. Can someone direct me to a lexicon of all these terms, one that explains in simple words what these things mean. Your help is greatly appreciated.

    derwalrosz

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: understanding syntax

    Excel, Office, and VBA have lots of enumerations (each starting with xl, mso, and vb respectively).

    If you look at Help for the Range.Delete method, you'll see that xlShiftToLeft and xlShiftUp belong to an enumeration called xlShiftDirection. If you enter

    ? xlShiftup

    ... in the VBE immediate window, you'll see it has a value of -4162.

    Or you could press F2 in the VBE to open the Object Browser, and type that in the search window to see the same thing.

    Learning how to use Help and the Object Browser is immensely valuable.
    Last edited by shg; 06-30-2012 at 02:05 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-19-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: understanding syntax

    shg, Thanks this was just what I needed.

    derwalrosz

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: understanding syntax

    Hi,

    Another way to look at this is:
    1. Computers work with numbers
    2. People work with words

    http://techsupt.winbatch.com/ts/T000001033005F9.html shows a bunch of words and what they translate to from English to Computer numbers.

    Here are some more constants: http://msdn.microsoft.com/en-US/libr...shaxd(v=vs.80)

    The idea is that instead of putting in a line of code that is Chr(10)&Chr(13) in VB code someone made english our of it and created vbCrLf.

    Here are some more constants for colors: http://msdn.microsoft.com/en-us/libr...8102(v=vs.110)

    Example: If in my VBA Immediate window I type "?vbGreen" and press enter it shows 65280. This is the number (for the computer) that goes with Green.

    As you can see there are lots and lots of pre-defined words in VB and VBA that we need to watch out for, and not use as our own variable names.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Registered User
    Join Date
    06-19-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: understanding syntax

    MarvinP,
    Thanks for the reply. I am not yet sure of how to use all of the information but I understand the general concept about numbers. I will continue slogging through it.
    Derwalrosz

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1