excelvbaformulaauto-update

Formula to daily update master table based on another sheet


I have one sheet where team leaders will daily input information. Now I need to create new master sheets that will be updated daily based on the above mentioned.

So now, for instance, in my main sheet there is range M28:O30 where TLs can mark employees' satisfaction choosing ":)" or ":(". In a new sheet I need to create table that will count daily the ":)" and ":(" adding new row with daily information each day. This is how the daily table looks like:

Daily table, where TLs will be introducing data everyday

And I would like to the data be summarized in such simple table:

New Master table created based on Daily Table

I did simple formula =COUNTIF but it doesn't create new row with data each date of course.

I am sure that it is doable with VBA but I was wandering if it was possible to achieve with formulas without going into coding. If I have to code, could someone help?

Many thanks in advance!


Solution

  • I highly doubt that there would be a complete "non code" solution to this. But here is a very minimal solution, that could run once the TL closes the workbook.

    Basically you'd have to prefill your 2nd sheet with the dates of this year (or whatever date range you want to include) and then fill column B4 all the way to end with this formula (note that I've called your master data sheet "Master"):

    =IF($A4<>TODAY(),"",COUNTIF(Master!$M$28:$O$30,$B$3))
    

    And for column C do the same thing but with

    =IF($A4<>TODAY(),"",COUNTIF(Master!$M$28:$O$30,$C$3))
    

    What this will do is it'll calculate the countif but only if it's the current day. So all later entries will show up empty. To keep the previous ones, we'll just need a short macro, that will copy the formula of the current day and paste it as values. Something like this:

    Option Explicit
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    
     Call PasteValuesCurrentDay     'This will just call the macro before closing of the map
    
    End Sub
    
    Sub PasteValuesCurrentDay()
    
    Dim yourWB As Workbook
    Dim sf As Worksheet
    
    Dim lr As Long, r As Long
    
    Set yourWB = ThisWorkbook
    Set sf = yourWB.Sheets("Satisfaction")  'I've called the worksheet with the table satisfaction
    
    lr = sf.Range("A1048576").End(xlUp).Row 'this will automatically give you the last row of your table
    
    'loop through all entries of your table
    For r = 4 To lr
        If sf.Range("A" & r) = Date Then    'if you find the entry for the current date then do something
            sf.Range("B" & r & ":C" & r).Copy               'Copy the values in B and C in the row with the current date
            sf.Range("B" & r).PasteSpecial xlPasteValues    'Paste it as values to prevent the formula result from changing the next day
        End If
    Next r
    
    yourWB.Save 'save because otherwise your macro will have ran for nothing
    
    End Sub
    

    You'd have to include this in the "ThisWorkbook" section of your workbooks vba code.