+ Reply to Thread
Results 1 to 9 of 9

Dim?

  1. #1
    Registered User
    Join Date
    04-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    25

    Dim?

    New-ish guy back again. Will someone in plain English tell me what is DIM in VBA and why do you use it?

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Dim?

    DIM is short for Dimension, you use it to declare variables.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Dim?

    And declaring variables allows the programming to reserve memory for the information, to know how much memory to reserve, and to know what type of information that variable will hold. This will allow the programming to use memory and processor time more efficiently, causing your code to run faster.

  4. #4
    Registered User
    Join Date
    04-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Dim?

    Thanks now I know what they are. How are they used? Or where can I go to learn more about how to use them?

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Dim?

    The following code declares variables
    Please Login or Register  to view this content.
    What I find to be most valuable about declaring variables is that it helps to enable the intellisense while coding. If you want to test the intellisense, re-write the code I gave line by line and you'll see what i mean.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Dim?

    Also, by declaring Option Explicit at the top of each module, you will be forced to declare variables, which helps a lot. For instance, with the same code as the previous post:
    Please Login or Register  to view this content.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Dim?

    There's some notes that I put together here

  8. #8
    Registered User
    Join Date
    04-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Dim?

    Thanks everyone. This really helps me understand dim and how to use it. This is awesome.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Dim?

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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