+ Reply to Thread
Results 1 to 4 of 4

Passing variable value from Private Sub to Module

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Passing variable value from Private Sub to Module

    I am trying to pass a variable called "Filter" from a Private Sub to a Module but keeping coming up with a zero value in the Module. I tried to make the variable Global but that didn't seem to work. Any suggestions for a solution is appreciated. Thanks.

    Private Sub Code as follows:
    Please Login or Register  to view this content.
    Global Variables as follows:
    Please Login or Register  to view this content.
    Module Code as follows:
    Please Login or Register  to view this content.
    Last edited by maacmaac; 08-12-2009 at 08:38 AM.

  2. #2
    Forum Contributor
    Join Date
    06-14-2008
    Posts
    153

    Re: Passing variable value from Private Sub to Module

    Hi,

    You are defining Filter in
    Please Login or Register  to view this content.
    So when you say
    Please Login or Register  to view this content.
    the value is assigned to the local variable and not the global one, and you will not get it in the module.

    Just remove
    Please Login or Register  to view this content.
    from
    Please Login or Register  to view this content.
    and hopefully that will resolve the problem.

    Regards.
    Welcome to: http://www.exceldigest.com/myblog/
    "Excel help for the rest of us"

  3. #3
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Passing variable value from Private Sub to Module

    Personally I'd get rid of the Global variables unless you really need them (ie. can justify a reason for having them other than needing the values in more that one function), and just pass them from one function to the next when you need to.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  4. #4
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Re: Passing variable value from Private Sub to Module

    Both suggestions are working fine. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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