Results 1 to 8 of 8

worksheetfunction countifs, counting down and across, application defined error

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    worksheetfunction countifs, counting down and across, application defined error

    Hi there,

    I am trying to come up with a VB solution that counts records based on conditions in VB. I have attached the file.

    In "Quarterly reports ALL" sheet, you see a table and ONLY B3 to Q19 need values to be populated by VB.

    The "IC collection" is where data gets collected.

    The following code is countifs using VB, but it's not quite working.

    n is the row counter on the report page while r is the column counter on the report page.

    Private Sub CommandButton1_Click()
    
    Dim n As Long
    Dim r As Long
    
    lastRowData = Worksheets("IC Data Collection").UsedRange.Rows.Count
    For n = 4 To 20
        For r = 2 To 16
        Worksheets("Quarter Reports ALL").Cells(n, r) = Application.WorksheetFunction.CountIfs(Worksheets("IC Data Collection").Range("H"), Worksheets("Quarterly Reports ALL").Cells(n, 1), Worksheets("IC Data Collection").Range("E"), Worksheets("Quarterly Reports ALL").Cells(3, r))
        
        Next r
        Next n
    
        End
    
    End Sub
    When I run the code, I get the application-defined error. I must have got the range target wrong or some sort of syntax error, but I'm not sure.

    Anyone able to assist?

    Thanks
    Attached Files Attached Files
    Last edited by Lifeseeker; 08-16-2012 at 11:57 AM.

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