+ Reply to Thread
Results 1 to 3 of 3

Setting ranges or values for all modules and this subs - Quick one

  1. #1
    Registered User
    Join Date
    04-03-2014
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    27

    Setting ranges or values for all modules and this subs - Quick one

    Hi

    I cannot seam to find the answer to how you will set for instance a range for all modules. For instance:
    Public MyArray as Range

    How do I then set MyArray to e.g. "A1" so i can use the specified range in all my modules and subs? Is it possible also for values?


    Thank you in advance for your reply :-)!



    damp

  2. #2
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Setting ranges or values for all modules and this subs - Quick one

    Put this in a module-
    Please Login or Register  to view this content.
    This will set the myarray to Cell A1 of Sheet1. This variable can now be used in other subs and modules.
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Setting ranges or values for all modules and this subs - Quick one

    Rather than a public Variable, you could use a Public Function.

    Please Login or Register  to view this content.
    That way, the syntax for its use would be exactly the same, but it wouldn't loose its value if there is a run-time error or if an End command is executed.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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. Is there a quick way of setting up data tables?
    By mrvp in forum Excel General
    Replies: 6
    Last Post: 05-17-2014, 03:42 PM
  2. Module Subs executing Private Subs without prompt by code - Totally Lost
    By Ozan Ertem in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-26-2012, 05:31 PM
  3. quick problem with date ranges
    By BlackfireMD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-22-2011, 01:06 AM
  4. Runtime Error 1004 when Setting Setting Series Values
    By tonymctigue in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-09-2010, 10:05 AM
  5. many subs or many modules
    By webby2006 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-03-2006, 09:02 AM
  6. Two Quick Questions: Calling Subs & Text Input boxes
    By ph8 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-29-2005, 10:25 AM
  7. Quick Question about variable ranges
    By lawin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2005, 10:27 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