Results 1 to 8 of 8

Thread: Weird VBA behavior

Hybrid View

  1. #1
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Weird VBA behavior

    To know why it does that, we'll almost certainly need to see the code.

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    Re: Weird VBA behavior

    K, what parts, i've made a few functions and stuff....heres one of the main functions....

    VB Code:
    1. Function totalPGEPump()
    2.  
    3.     Dim colName As String
    4.     Dim pltName(1 To 17) As String
    5.     Dim pltType As String
    6.     Dim nDay As Long
    7.     Dim day As Long
    8.     Dim nHour As Long
    9.     Dim hour As Long
    10.     Dim i As Long
    11.     Dim pltRow As Long
    12.     Dim subRow As Long
    13.     Dim totalNameCell As String
    14.     Dim functionName As String
    15.     Dim colNameNum As Long
    16.     Dim hourlyTotalArray(30, 24) As Double
    17.     Dim totalPlants As Long
    18.     'pltType is the type of the plants that are being totaled
    19.     pltType = "Pump"
    20.     'functionName is the name that will appear as the blocks title in the worksheet
    21.     functionName = "PG&E Area " & pltType
    22.     'totalNameCell is the cell in which the name will appear
    23.     totalNameCell = "AP1893"
    24.     Cells((detExlRow(totalNameCell)), detExlCol(totalNameCell)) = functionName
    25.  
    26.    
    27.     'the column in which the names of the plants are listed.
    28.     'use the first cell in that column.
    29.     colName = "AQ1"
    30.     colNameNum = detExlCol(colName)
    31.     'Names of the plants in no order.  Add more by increasing the 'dim' above _
    32.     'and also by increasing the while loop below.
    33.    
    34.     pltName(1) = "Badger Hill"
    35.     pltName(2) = "Banks"
    36.     pltName(3) = "Barker Slough"
    37.     pltName(4) = "Bluestone"
    38.     pltName(5) = "Buena Vista"
    39.    
    40.     pltName(6) = "Chrisman"
    41.     pltName(7) = "Cordelia (new)"
    42.     pltName(8) = "Del Valle"
    43.     pltName(9) = "Devils Den"
    44.     pltName(10) = "Dos Amigos"
    45.  
    46.     pltName(11) = "Gianelli"
    47.     pltName(12) = "Hyatt"
    48.     pltName(13) = "Las Perillas"
    49.     pltName(14) = "Polonio"
    50.     pltName(15) = "South Bay"
    51.    
    52.     pltName(16) = "Teerink"
    53.     pltName(17) = "Therm"
    54.    
    55.     i = 1
    56.     subRow = detExlRow(totalNameCell)
    57.    
    58.     totalPlants = 17
    59.    
    60.     nDay = 30 - 1
    61.     day = 0
    62.     nHour = 23
    63.     hour = 0
    64.    
    65.     While i <= totalPlants
    66.         pltRow = searchForPlantName(colName, pltName(i), pltType)
    67.    
    68.         While day <= nDay
    69.             While hour <= nHour
    70.                 hourlyTotalArray(day, hour) = hourlyTotalArray(day, hour) + Cells(pltRow + day, colNameNum + 1 + hour)
    71.                 hour = hour + 1
    72.             Wend
    73.             day = day + 1
    74.             hour = 0
    75.         Wend
    76.         day = 0
    77.         i = i + 1
    78.     Wend
    79.    
    80.     While day <= nDay
    81.         While hour <= nHour
    82.             Cells(subRow + day, colNameNum + 1 + hour) = hourlyTotalArray(day, hour)
    83.             hour = hour + 1
    84.         Wend
    85.         day = day + 1
    86.         hour = 0
    87.     Wend
    88. End Function



    Lemme know if you want some more, or certian functions from this peice.


    Sorry bout the wrong forum thing...


    EDIT: Lost all my formating, sorry.
    Last edited by si_the_geek; Jul 14th, 2006 at 02:27 PM. Reason: added vbcode tags

Posting Permissions

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



Click Here to Expand Forum to Full Width