+ Reply to Thread
Results 1 to 2 of 2

Option Explicit, Integers, Long

  1. #1
    Forum Contributor
    Join Date
    03-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    491

    Option Explicit, Integers, Long

    Can someone explain why you put that in the beginning of Macros?

    When I see Dim As "Integer" or Dim As "Long" How do I interpret the characteristics of these variables?

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Option Explicit, Integers, Long

    swade730,

    Option Explicit, Integers, Long
    Can someone explain why you put that in the beginning of Macros?
    When you use Option Explicit, you are telling VBA that you want to define your variables.

    This is a good programming practice.

    This way, when there is a problem with the macro code, someone else will be able to better understand the code, and, find a the problem if one exists.

    Integer numbers range in value from -32,768 to 32,767.

    Long numbers range in value from -2,147,483,648 to 2,147,483,647.


    When I program in VBA I always use LONG - this is a personal preference.

    Here's a good primer on the scope of variables.
    http://www.cpearson.com/excel/scope.aspx

    Using Variables in Excel VBA Macro Code
    http://www.ozgrid.com/VBA/variables.htm

    For more good information:
    On reply #38, there are a lot of links for information and training. Check it out.
    http://www.excelforum.com/excel-prog...terials-4.html
    Last edited by stanleydgromjr; 08-13-2013 at 07:37 PM.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Option Explicit
    By Marianus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2013, 05:01 AM
  2. Dim in Option Explicit
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 03-22-2011, 03:47 PM
  3. Option Explicit and Dim ds as what?
    By leaning in forum Excel General
    Replies: 3
    Last Post: 10-20-2010, 03:50 PM
  4. [SOLVED] Option explicit
    By Alexandre Brisebois (www.pointnetsolutions.com) in forum Excel General
    Replies: 1
    Last Post: 07-25-2005, 12:05 PM
  5. Option Explicit
    By Piranha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-05-2005, 11:18 PM

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