+ Reply to Thread
Results 1 to 6 of 6

Public variables

  1. #1
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Public variables

    I have a sheet with quite a few variables publicly defined in the macro. We have also been experiencing some issues with other sheets opening slowly. The below is the list of these variables by type

    Integer 23
    Long 1
    Name 1
    Range 4
    String 33
    Variant 17
    Worksheets 1
    Date 4
    1D array 1
    2D array 1

    The two arrays are not very large arrays.

    Is this likely that this many public variables would be the cause an issue? Or is this not too many? Is there a limit?

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

    Re: Public variables

    Hi scottiex,

    I can't see why your list of public variables would slow things down much. Do you have array formulas or lots of conditional formatting or perhaps a User Defined Function? Those might be more likely the cause of slowing things down.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Public variables

    Marvin,

    there are quite a few formula but It doesn't seem to be a calculations issue. Causing recalculation takes basically no time at all.

    the symptoms I'm trying to diagnose are that it seems to be less stable (it crashes with the out of memory VBA message sometimes although I seem to be the only one getting that at the moment) and a user was complaining that it was slow to open their CSV files while it was open.

    I expect it is pretty hard to diagnose the issue. If we can say it is unlikely to be the variables that is useful to know and I wont bother going through the process of trying to redesign that part of the code.

  4. #4
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Public variables

    You can use more public variables. In your case may be you are having some other issues. But it is tough to say without seeing the file.

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

    Re: Public variables

    If you do VBA right after a file open you might have problems. If you pass control to the OS it is a good idea to follow that line with a "DoEvents" statement. This allows the OS to finish what it is doing before the next line of VBA is run.

    https://support.microsoft.com/en-us/kb/118468

  6. #6
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Public variables

    Thanks for that Marvin,
    That may well be a factor in this.

+ 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. [SOLVED] Public variables
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2015, 04:25 PM
  2. [SOLVED] Public Variables
    By iamGreenhorn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-21-2014, 12:38 PM
  3. Public Variables
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2008, 03:56 PM
  4. Public variables
    By Tomski in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2006, 10:20 AM
  5. Public Variables
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-01-2005, 12:05 PM
  6. [SOLVED] Public Variables
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-21-2005, 07:06 AM
  7. Public variables
    By jcp29 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-02-2005, 07:10 PM

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