+ Reply to Thread
Results 1 to 2 of 2

Using Variables between Module and User Form

  1. #1
    Registered User
    Join Date
    01-17-2013
    Location
    Austin, TX
    MS-Off Ver
    Excel 2007
    Posts
    84

    Using Variables between Module and User Form

    Hello,
    I'm trying to create a macro that will copy and paste values from several workbooks into one sheet and create a chart. With the command button, I would like it always to use just the range and loop through the workbook's sheets. However, when trying to use the code I get an runtime error of 91 which says, "With block variable or object variable not set". The only way I could think of solving this would be to add the chart_magic macro into the command button, but that seems kind of ugly. There's got to be a better way.

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

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,164

    Re: Using Variables between Module and User Form

    Hi rbirch,

    Without reading all your code, it sounds like you need a Public Global Variable that works until the workbook is closed. See:

    http://www.ozgrid.com/VBA/variable-scope-lifetime.htm

    http://www.excel-easy.com/vba/exampl...ble-scope.html
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ 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. Replies: 0
    Last Post: 01-08-2013, 06:03 PM
  2. How to make button in user form call a module
    By TomT in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2012, 11:01 AM
  3. [SOLVED] pass variable for user form module to function
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2012, 10:10 PM
  4. Passing variables from sub to user form
    By boc_est1986 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-18-2009, 09:09 AM
  5. Showing User Form in a Custom Module
    By ions in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2009, 04:41 PM

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