+ Reply to Thread
Results 1 to 5 of 5

Referencing a task outside of a sub then continuing within the original sub

  1. #1
    Registered User
    Join Date
    12-18-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    30

    Referencing a task outside of a sub then continuing within the original sub

    I am running into a situation that I have multiple subs that overall do different things but a portion of them do the same thing. The issue is if I find I must change that code, I have to go to 5 different subs to make the change.

    Is there a way I can write a task of some sort that I can just reference but my specific sub continues on? This way I will only have to change 1 location.


    Here is an example...

    Please Login or Register  to view this content.

    I am not sure if I explained this right but thank you!

    Max

  2. #2
    Registered User
    Join Date
    06-24-2016
    Location
    UK
    MS-Off Ver
    Excel 2013
    Posts
    24

    Re: Referencing a task outside of a sub then continuing within the original sub

    This should really be in the VBA section of this forum; hopefully a mod will move it to its correct place for you.

    To reference a sub, all you need to do is to create a new one, containing the parts that you want to reference, e.g.


    Please Login or Register  to view this content.
    Then in your subs that you want to call this, just add the line:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-18-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    30

    Re: Referencing a task outside of a sub then continuing within the original sub

    Sorry I didn't notice that prior to posting.

    The problem with that is that as soon as the new sub test ends, the vba stops. I want it to return to the origional sub and continue on.

  4. #4
    Registered User
    Join Date
    06-24-2016
    Location
    UK
    MS-Off Ver
    Excel 2013
    Posts
    24

    Re: Referencing a task outside of a sub then continuing within the original sub

    If you call the Test sub from within another sub, it should just run the Test sub, then continue back I. Your original sub.
    Have you tried stepping through the code, using F8, to see at what point it stops?

  5. #5
    Registered User
    Join Date
    12-18-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    30

    Re: Referencing a task outside of a sub then continuing within the original sub

    Yes you are correct. I have to go back to one of my other sheets and figure out why I could not get it to work. Thank you for pointing this out to me.

+ 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. Replies: 5
    Last Post: 03-30-2016, 12:32 PM
  2. [SOLVED] How to copy formulas to new workbook without referencing original source
    By TPS in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-11-2013, 08:47 PM
  3. Copy/Paste Referencing Only Original Cell (Conditional Formatting)
    By JONBOY666 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-30-2013, 06:26 PM
  4. Copied macro keeps referencing original worksheet?
    By c2q in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2012, 10:28 PM
  5. Referencing original sheet to copy/paste into new sheet without using file name
    By pgarakani in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2012, 02:06 PM
  6. copy and paste without referencing original sheet
    By tinkerist in forum Excel General
    Replies: 3
    Last Post: 04-07-2012, 08:26 PM
  7. [SOLVED] copy PROTECTED worksheet without referencing original
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2005, 06:05 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