+ Reply to Thread
Results 1 to 1 of 1

Global variable out of context

Hybrid View

  1. #1
    Registered User
    Join Date
    09-01-2011
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    78

    Global variable out of context

    I have a variable which changes every time the worksheet opens. I declare it as public so that it can be passed to a procedure.
    Public APLastCol As Long
    
    Sub ... ()
    ...
    
    Static nColorIndices As Variant
            ReDim nColorIndices(1 To APLastCol)
    ...
    
    End Sub
    
    Private Sub Workbook_Open()
    
      With Sheets("AB")
            APLastCol = .Cells(1, Sheets("AB").Columns.Count).End(xlToLeft).Column
        End With
    
    End Sub
    For some reason I can't get the count of the columns into the public variable. The watch shows it as being "out of context" and then my procedure does not work properly.


    Any ideas?
    Last edited by labogola; 01-08-2012 at 06:58 PM.

+ 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