Consulting

Results 1 to 3 of 3

Thread: Prevent variable from being initialized

  1. #1
    VBAX Regular
    Joined
    Apr 2009
    Posts
    59
    Location

    Prevent variable from being initialized

    Hello,

    I run the macro
    [VBA]
    Sub main()
    Call check(Workbooks("Outlier").Sheets("Spreadsheet").range("A30:A600"))
    End Sub
    [/VBA]

    In this check function, it runs through my spread sheet and when it finds something to print, it checks that it hasnt been printed before. It uses this (inside a sub that is called inside check)

    [VBA] For I = 1 To (warning_rows)
    If (Minute(Now) > refresh_rate + mytimes(I) And mynames(I) = C.Value) Then
    Exit Sub
    End If
    Next I[/VBA]

    And everytime i write something, i memorize it in those two arrays:
    [VBA] myindicators(counter(which), which) = Indicator
    mytimes(counter(which), which) = Minute(Now)[/VBA]

    The problem is that as the main macro runs over and over again, the arrays myindicators and mytimes seem to get initialized and so the check for duplication is not sufficient.

    How would I prevent those arrays from being initialized?

    Thank you!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Where have you declared those arrays? Make them public before any macros in the module.
    Last edited by Bob Phillips; 05-08-2009 at 08:38 AM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Apr 2009
    Posts
    59
    Location
    Great, i declare them as Public in a separate module. Thanks very much!!
    Last edited by frubeng; 05-08-2009 at 07:40 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •