Results 1 to 5 of 5

Thread: [RESOLVED] [Excel] Workbook Function Error with Variables

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2010
    Location
    Durham, NC
    Posts
    5

    Resolved [RESOLVED] [Excel] Workbook Function Error with Variables

    Hi Everyone!

    I am trying to create a final table of statistical data from a large database export. I have been successful at parsing the data into a new workbook by sheets, now I just need to run some basic Excel stats functions on one column in each sheet and have the results displayed in one table. However, I get the runtime Error 1004 at line 19 in my following code:
    Code:
    1.    ' Populate table with analyte information
    2.    Dim iSheetCount As Integer
    3.    Dim iSheet As Integer
    4.    Dim totalrows As Integer
    5.    Dim dMedian As Integer
    6.    Dim dMode As Integer
    7.    Dim dQuartile1 As Integer
    8.    Dim dQuartile3 As Integer
    9.    Dim dGeoMean As Integer
    10.            
    11.   iSheetCount = ActiveWorkbook.Worksheets.Count
    12.   For iSheet = 2 To iSheetCount - 2
    13.   Worksheets(iSheet).Activate
    14.    
    15.        For i = 3 To 7
    16.        ' Define Stats for table
    17.            totalrows = ActiveSheet.UsedRange.Rows.Count
    18.            dMedian = WorksheetFunction.Median(Columns(totalrows, 7))
    19.            dMode = WorksheetFunction.Mode(Columns(totalrows, 7))
    20.            dQuartile1 = WorksheetFunction.Quartile(Columns(totalrows, 7), 1)
    21.            dQuartile3 = WorksheetFunction.Quartile(Columns(totalrows, 7), 3)
    22.            dGeoMean = WorksheetFunction.GeoMean(Columns(totalrows, 7))
    23.        ' Populate table with stats
    24.            Sheets("Table").Cells(i, 3).Value = dMedian
    25.            Sheets("Table").Cells(i, 4).Value = dMode
    26.            Sheets("Table").Cells(i, 5).Value = dQuartile1
    27.            Sheets("Table").Cells(i, 6).Value = dQuartile3
    28.            Sheets("Table").Cells(i, 7).Value = dGeoMean
    29.                
    30.        Next i
    31.    
    32.    Next iSheet
    Is it possible to work with variables in function commands? Did I make an error in my semantics? Any help with be GREATLY appreciated!!

    Thank you so much!
    Last edited by funkykizzy; Nov 1st, 2010 at 01:59 PM. Reason: I forgot to add my question in at the bottom ;)

Tags for this Thread

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