+ Reply to Thread
Results 1 to 7 of 7

Option Explicit and what looks like an undeclared variable despite no error reported

  1. #1
    Registered User
    Join Date
    08-13-2014
    Location
    Cumbria, uk
    MS-Off Ver
    2007
    Posts
    12

    Unhappy Option Explicit and what looks like an undeclared variable despite no error reported

    Hi

    I hope someone can help me. I've inherited some VBA code and I'm trying to understand it.

    I have 3 separate functions as follows:-

    Function PDelay#(TrafficC#, Servers%)
    Defined as (1.33, ????
    Dim Part1#, Part2#, CommonPart#, Counter%

    Function SLevel#(Calls#, AHT#, Period%, SLO%, Servers%)
    Defined as 8, 300, 1800, 20, ????
    Dim Traffic#, PZero#

    Function Staffing%(Calls#, AHT#, Period%, SLO%, SLA#, LimOccupancy#)
    Defind as 8, 300, 1800, 20, 0.8, 0.85
    Dim Traffic#, SrvcLvl#

    I've managed to follow the variables listed above with the staffing% function being used as a formula in cells. The others functions are not. I can't seem to find a definition of the servers% variable. There's nothing in the rest of the code defining servers# and I'm completely stuck. If it's easier to publish the whole code I can do so. Does it have to be defined as per the Dim statement? I'm completely lost.

    Any help would be appreciated.

    Thanks in advanced.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Option Explicit and what looks like an undeclared variable despite no error reported

    You need to post the whole code. Use code tags: [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] .

    What does: Defined as (1.33, ????, et al., mean?
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    08-13-2014
    Location
    Cumbria, uk
    MS-Off Ver
    2007
    Posts
    12

    Re: Option Explicit and what looks like an undeclared variable despite no error reported

    Hi

    Thanks for responding. The Defined as was me putting a number to the variable. Just ignore it. Code below for all 3 funtions:-

    Please Login or Register  to view this content.
    Hope you can help.

    Thanks

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Option Explicit and what looks like an undeclared variable despite no error reported

    Function Staffing% has a line:

    SrvcLvl# = SLevel#(Calls#, AHT#, Period%, SLO%, Staffing%)
    calling SLevel#, note that the fifth argument "Staffing%" is passed to Servers% in the function SLevel#

    Slevel# calls PDelay passing Servers% as the second argument. Note that the Servers# in PDelay argument list is not the same as the one in SLevel, they are two different variables local to each function.
    Please Login or Register  to view this content.
    Last edited by protonLeah; 07-25-2015 at 04:08 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Option Explicit and what looks like an undeclared variable despite no error reported

    The person that takes over code maintenance from you would hate you less if you redid the declarations:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    08-13-2014
    Location
    Cumbria, uk
    MS-Off Ver
    2007
    Posts
    12

    Re: Option Explicit and what looks like an undeclared variable despite no error reported

    Thanks shg

    I hear what you're saying. This is me trying to take over code maintenance from someone else. Pure nightmare. Especially when you haven't dealt with Option Explicit before. Thanks for the restructure.

  7. #7
    Registered User
    Join Date
    08-13-2014
    Location
    Cumbria, uk
    MS-Off Ver
    2007
    Posts
    12

    Re: Option Explicit and what looks like an undeclared variable despite no error reported

    Thanks protonLeah. Lot clearer now.

    And with shg's new layout it makes it a lot more familiar. I assume the % and # were the old declarations which I've never seen before.

    Thanks again.

+ 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. Option Explicit
    By Marianus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2013, 05:01 AM
  2. [SOLVED] Option Explicit Error - Variable Declaration
    By exc4libur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2012, 05:38 PM
  3. Dim in Option Explicit
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 03-22-2011, 03:47 PM
  4. Option Explicit and Dim ds as what?
    By leaning in forum Excel General
    Replies: 3
    Last Post: 10-20-2010, 03:50 PM
  5. [SOLVED] Undeclared variables allowed in a Module defined with Option Expli
    By cgr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2006, 11:25 AM
  6. [SOLVED] Option explicit
    By Alexandre Brisebois (www.pointnetsolutions.com) in forum Excel General
    Replies: 1
    Last Post: 07-25-2005, 12:05 PM
  7. Option Explicit
    By Piranha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-05-2005, 11:18 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