+ Reply to Thread
Results 1 to 4 of 4

Passing value of variant

  1. #1
    Andrew
    Guest

    Passing value of variant

    Hi,

    I have a button on a userform. The userform is displayed after pressing a
    button on a worksheet, called from a peice of code.

    UserForm1.Show

    Upon pressing the button a value is set (eg x = 1).

    How do I pass the value for x back to the original code? I have tried using

    'Public x as Variant'.

    --
    Andrew

  2. #2
    Tom Ogilvy
    Guest

    Re: Passing value of variant

    use
    Public x as Variant

    in a general module - the type you get if you do Insert=>Module

    then it is visible to the entire project.

    --
    Regards,
    Tom Ogilvy

    "Andrew" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I have a button on a userform. The userform is displayed after pressing a
    > button on a worksheet, called from a peice of code.
    >
    > UserForm1.Show
    >
    > Upon pressing the button a value is set (eg x = 1).
    >
    > How do I pass the value for x back to the original code? I have tried

    using
    >
    > 'Public x as Variant'.
    >
    > --
    > Andrew




  3. #3
    Andrew
    Guest

    Re: Passing value of variant

    Hi Tom,

    I've tried putting that statement in both the module and code on the form.
    I have a watch on 'x' and when the code goes back to the module code the
    watch value goes to '<out of context>'
    --
    Andrew


    "Tom Ogilvy" wrote:

    > use
    > Public x as Variant
    >
    > in a general module - the type you get if you do Insert=>Module
    >
    > then it is visible to the entire project.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Andrew" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > I have a button on a userform. The userform is displayed after pressing a
    > > button on a worksheet, called from a peice of code.
    > >
    > > UserForm1.Show
    > >
    > > Upon pressing the button a value is set (eg x = 1).
    > >
    > > How do I pass the value for x back to the original code? I have tried

    > using
    > >
    > > 'Public x as Variant'.
    > >
    > > --
    > > Andrew

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: Passing value of variant

    Well, I didn't say anything about putting it (the declaration) in the code
    on the form.

    That just defeats the whole purpose.

    --
    Regards,
    Tom Ogilvy

    "Andrew" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Tom,
    >
    > I've tried putting that statement in both the module and code on the form.
    > I have a watch on 'x' and when the code goes back to the module code the
    > watch value goes to '<out of context>'
    > --
    > Andrew
    >
    >
    > "Tom Ogilvy" wrote:
    >
    > > use
    > > Public x as Variant
    > >
    > > in a general module - the type you get if you do Insert=>Module
    > >
    > > then it is visible to the entire project.
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "Andrew" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Hi,
    > > >
    > > > I have a button on a userform. The userform is displayed after

    pressing a
    > > > button on a worksheet, called from a peice of code.
    > > >
    > > > UserForm1.Show
    > > >
    > > > Upon pressing the button a value is set (eg x = 1).
    > > >
    > > > How do I pass the value for x back to the original code? I have tried

    > > using
    > > >
    > > > 'Public x as Variant'.
    > > >
    > > > --
    > > > Andrew

    > >
    > >
    > >




+ 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