+ Reply to Thread
Results 1 to 4 of 4

Convert to Function?

  1. #1
    Registered User
    Join Date
    04-04-2015
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 365
    Posts
    88

    Convert to Function?

    Hi,
    Three of my subs in module have the exact same part of the script that does the same thing and I wish I could put it in function but I don't know how... I had trouble because the two variables (strLine and clrLine) rely on each other.

    Please Login or Register  to view this content.
    I've highlighted the two portions I would like to "convert" to function. Could you show me how?

  2. #2
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    20,805

    Re: Convert to Function?

    There are three variables used in both pieces of code, so I made those arguments to the new Sub. These also had to be declared locally in the first sub. I don't know what this code is supposed to be doing so I didn't test it, but I did compile it. I called your new Sub Sub2. Maybe you have a better name if you know what it does.

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    05-01-2015
    Location
    Atlanta, Georgia
    MS-Off Ver
    2010
    Posts
    2

    Re: Convert to Function?

    I'm not exactly sure what you are trying to do with the first piece of code you are wanting to make into a function. All it is doing is declaring and setting some initial values to variables.

    The second section is very easily made into a function that you can then call. See code below:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-04-2015
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 365
    Posts
    88

    Re: Convert to Function?

    Thank you guys, it works perfectly

+ 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. Convert into sumproduct function.
    By husni in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-25-2014, 05:49 AM
  2. Convert Function
    By staccee in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-11-2013, 10:37 AM
  3. what function to convert convert 34234 to 99999
    By archiles in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-04-2008, 11:26 PM
  4. Need a function to convert value in its name
    By Abraham in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-12-2006, 11:03 PM
  5. Convert function
    By D in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-05-2006, 01:55 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