+ Reply to Thread
Results 1 to 4 of 4

Thread: CountIf Macro

  1. #1
    Registered User
    Join Date
    10-17-2008
    Location
    US
    Posts
    36

    CountIf Macro

    I need to add to a current macro which currently copies the master tab and creates a new tab with tomorrow's date on it. For reference here is the current macro:

     Dim TodayDate As Date
     Dim DashDate As Date
     Dim DashDate_text As String
     
     Dim T_Date As Date
     
     T_Date = (Date + 1)
     
     TodayDate = Format(T_Date, "mm/dd/yy")
     
     DashDate = (Date + 1)
     
     DashDate_text = Format((DashDate), "dd")
     Tabdate = Format(DashDate, "dd")
     
        
        Sheets("Master").Select
        Sheets("Master").Copy After:=Sheets("Master")
        Sheets("Master (2)").Select
        Sheets("Master (2)").Name = Tabdate
    I want to add a bit that opens P:\Call Center Operations\checkin.xls and looks in Column D for the values HRRESL, HRRERN, TVREAS & HRRETA and places the counts in B12, B13, B15 & B18 of tomorrow's tab in the main workbook, respectively.

    I think I mainly need help in wording a CountIf statement for the four values. I am fairly certain I can figure the rest out. (but if I can't you'll hear from me)

    Thanks ahead of time ... cuz I KNOW ya'll rock!!
    Last edited by delirium; 06-01-2009 at 07:35 PM.

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: CountIf Macro

    Maybe like this (completely untested):
    Sub x()
        Dim wks As Worksheet
        
        Worksheets("Master").Copy After:=Worksheets("Master")
        Set wks = ActiveSheet
        wks.Name = Format(Date + 1, "dd")
        
        Workbooks.Open "P:\Call Center Operations\checkin.xls"
        
        With wks.Range("B12:B18")
            .Cells(1).Formula = "=countif('[checkin.xls]Sheet1'!D:D, ""RRESL"")"
            .Cells(2).Formula = "=countif('[checkin.xls]Sheet1'!D:D, ""HRRERN"")"
            .Cells(4).Formula = "=countif('[checkin.xls]Sheet1'!D:D, ""TVREAS"")"
            .Cells(7).Formula = "=countif('[checkin.xls]Sheet1'!D:D, ""HRRETA"")"
            .Value = .Value
        End With
        
        ActiveWorkbook.Close SaveChanges:=False
    End Sub
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    10-17-2008
    Location
    US
    Posts
    36

    Re: CountIf Macro

    Am I allowed to say that I love you?

  4. #4
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: CountIf Macro

    Just marking the thread Solved would be sufficient, thanks.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0