Results 1 to 3 of 3

VBA - Simple example for passing a variable between modules

Threaded View

Ryanside VBA - Simple example for... 03-14-2012, 06:15 AM
Andrew-R Re: VBA - Simple example for... 03-14-2012, 06:20 AM
Ryanside Re: VBA - Simple example for... 03-14-2012, 06:33 AM
  1. #1
    Registered User
    Join Date
    08-16-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2000
    Posts
    4

    Question VBA - Simple example for passing a variable between modules

    After getting to know VBA quite well there is still one issue I am having, I can't seem to get my head around passing values between modules. I hope someone here might be able to aid me in a simple theoretical example that will help me and hopefully others.

    Sub module1()
    
       Dim x As Integer
    
       'general code
       'general code
       'general code
    
       x = Sheet1.Range("A1").Value
       call module2
    
       'continue code
    
    End Sub


    Sub module2()
    
       Dim y As Integer
    
       y = x + 10
    
    End Sub

    All I am after is for someone to point me in the right direction on how to pass variable x to the second module, and then return y back to module1 and continue with the new calculated value.

    Many thanks in advance!

    Ryan.
    Last edited by Ryanside; 03-15-2012 at 07:49 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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