+ Reply to Thread
Results 1 to 2 of 2

Sub Declaration

Hybrid View

  1. #1
    Registered User
    Join Date
    01-17-2014
    Location
    Egypt
    MS-Off Ver
    Excel 2010
    Posts
    25

    Sub Declaration

    Hi

    I hope someone can answer my general query.

    Sometimes i find the routine Sub is written as
    Sub ReadArrayFromExcel(Arr() As Variant, r As Range)
    What is the difference between this and:

    Sub ReadArrayFromExcel()
    Dim Arr() As Variant, r As Range
    Thanks!

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Sub Declaration

    Hi,
    In the first version, you need to declare, set and then pass values to the sub to make in work, something like:

    Sub Test
    dim Your_Array as Variant
    Dim Your_Range as Range
    
    Your_Array = Something
    Set Your_Range = Something
    
    Call ReadArrayFromExcel(Your_Array, Your_Range)
    'or
    ReadArrayFromExcel Your_Array, Your_Range
    End Sub
    While in the second version, you declare and set your variable in the sub directly.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

+ 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. Using Declaration
    By nathansav in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-06-2013, 10:55 AM
  2. [SOLVED] Variables declaration
    By nikolaygeorgiev in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-27-2013, 11:15 AM
  3. DLL function Declaration
    By rkappa in forum Excel General
    Replies: 0
    Last Post: 03-14-2007, 10:25 AM
  4. [SOLVED] if declaration
    By ashw1984 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2006, 03:40 PM
  5. Declaration problem
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-25-2005, 12:03 AM
  6. [SOLVED] VBA Declaration problem
    By Shawn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2005, 06:05 PM
  7. Declaration name
    By Robert Hargreaves in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-06-2005, 12:05 PM

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