Results 1 to 4 of 4

help on macro to count single so and call type also

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-21-2011
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007,2010,2016
    Posts
    695

    help on macro to count single so and call type also

    i have set of date in A:A,B:B,C:C at last F:F column contains fill serial no{1,2,3,4.....}
    CRM DATE In A:A column
    SO In B:B column
    CALL TYPE In C:C column

    i have set of macro to count how many times its so gets repeats in column with LABOR ONLY & LABOR & PART in call type column C:C
    but now i calculates both LABOR ONLY & LABOR & PART which are available against so' other wise it gets error

    for e.g for if so DE3233334 only one time and call type LABOR ONLY i want result = "0"
    if so WEE412122 repeats four time but call type LABOR & PART repeats four time i want result as per date sort from min to max 0,1,2,3.

    please find the code

    Option Explicit
    
    
    
    
    Sub testone()
        Dim so As Range, calltype As Range, unq1 As Range, unq2 As Range
        Dim cunq1 As Range, cunq2 As Range, r As Range, j As Integer, k As Integer
        Dim filt As Range
        Dim crm As Range, result As Range
        Application.ScreenUpdating = False
        Worksheets("sheet1").Cells.Clear
        Worksheets("sheet2").Cells.Copy Worksheets("sheet1").Range("A1")
        Worksheets("sheet1").Activate
        Set r = Range("a1").CurrentRegion
        r.Sort key1:=Range("B1"), key2:=Range("C1"), Header:=xlYes
        '=============
    
        Set so = Range(Range("B1"), Range("B1").End(xlDown))
        Set calltype = so.Offset(0, 1)
        Set unq1 = Range("A1").End(xlDown).Offset(5, 0)
        Set unq2 = unq1.Offset(0, 1)
        so.AdvancedFilter xlFilterCopy, , unq1, True
        calltype.AdvancedFilter xlFilterCopy, , unq2, True
        Set unq1 = Range(unq1.Offset(1, 0), unq1.End(xlDown))
        Set unq2 = Range(unq2.Offset(1, 0), unq2.End(xlDown))
        For Each cunq1 In unq1
            ActiveSheet.AutoFilterMode = False
            r.AutoFilter 2, cunq1
            For Each cunq2 In unq2
                r.AutoFilter 3, cunq2
                Set filt = r.Offset(1, 0).Resize(r.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
                Set crm = filt.Columns("A:A")
                'msgbox crm.Address
                Set result = filt.Columns("E:E")
                'msgbox result.Address
                j = filt.Rows.Count
                For k = 1 To j
                    result.Cells(k, 1) = WorksheetFunction.Rank(crm.Cells(k, 1), crm, 1) - 1
    
                Next k
    
    
            Next cunq2
            ActiveSheet.AutoFilterMode = False
        Next cunq1
    
        ActiveSheet.AutoFilterMode = False
        r.Sort key1:=Range("F1"), Header:=xlYes
        MsgBox "macro over"
        Application.ScreenUpdating = True
    End Sub
    here getting error like this msg(runtime error 1004 no cells were found
    stops at "
    Set filt = r.Offset(1, 0).Resize(r.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
    "

    find the attachment!!!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to write to multiple cells from a single function call
    By geophysicist in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-14-2013, 11:34 AM
  2. Repeat call count for call center
    By arifmasum in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-08-2013, 10:03 PM
  3. Replies: 0
    Last Post: 03-28-2013, 02:41 AM
  4. Method to call out a table from a single cell
    By erickpay in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2012, 02:04 PM
  5. How to set call count according to call date and time
    By naveen4pundir in forum Access Tables & Databases
    Replies: 0
    Last Post: 04-27-2012, 02:13 AM

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