+ Reply to Thread
Results 1 to 3 of 3

Variable values

  1. #1
    Ed
    Guest

    Variable values

    I've set up two macros "A" and "B" for use on a worksheet.

    I assigned a value say 4 to a variable "v" in macro A.

    I find that the value 4 does not carry over to a variable "v" in
    macro B.

    Is there a way to have the variables of macro A apply to all other
    macros used with the worksheet?

    Thanks,


    Ed

  2. #2
    Gary''s Student
    Guest

    RE: Variable values

    DIM the variable before the macros in the module:

    DIM v
    Sub a()
    ..
    ..
    ..
    End Sub
    Sub b()
    ..
    ..
    ..
    End Sub
    --
    Gary''s Student


    "Ed" wrote:

    > I've set up two macros "A" and "B" for use on a worksheet.
    >
    > I assigned a value say 4 to a variable "v" in macro A.
    >
    > I find that the value 4 does not carry over to a variable "v" in
    > macro B.
    >
    > Is there a way to have the variables of macro A apply to all other
    > macros used with the worksheet?
    >
    > Thanks,
    >
    >
    > Ed
    >


  3. #3
    Joerg
    Guest

    Re: Variable values


    "Ed" <eenglish@cox.net> wrote in message
    news:n0obd2httob5i6dpp5ot644fe65q4urq0o@4ax.com...
    > I've set up two macros "A" and "B" for use on a worksheet.
    >
    > I assigned a value say 4 to a variable "v" in macro A.
    >
    > I find that the value 4 does not carry over to a variable "v" in
    > macro B.
    >
    > Is there a way to have the variables of macro A apply to all other
    > macros used with the worksheet?


    If the macros are in one module: put a 'Dim v' statement at the beginning of
    the module (in the General section). Your variable will be recognizes in all
    macros (do not but a Dim v statement into any of your macros, this would
    override the general declaration.

    If macros are in separate modules, put a 'Public v' statement into the
    general section of any module.

    Joerg



+ 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