Hits, misses and false alarms monthly summary

drefiek2

Board Regular
Joined
Apr 23, 2023
Messages
72
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I need help creating a 'verification' monthly summary table and I will try to explain what I want using an example.
I have a spreadsheet with dates in column B starting from row 6 (1st Jan 2025 - 31st Dec 2025), these dates are merged cells over two rows, so rather than 365 rows there are 730 rows.
I have cities in Europe along row 5 columns D to J.
For each date I have 'Sunny Forecast' and 'Observation', what someone will do is forecast whether it will be sunny in those cities on that date and either put a 0 for yes (green flag) or a 1 for no (red flag).
The next day they will verify whether it was sunny or not, by again putting a 0 or 1.
If both are 0 for that date then it is a 'hit', if both are 1 for that date then it is also a 'hit', if the forecast is a 0 but the observation is a 1 then it is a 'miss', if the forecast is a 1 but the observation is a 0 then it is a 'false alarm'. This probably sounds strange but it is just an example!
Essentially what I want to be able to do is in a blank table on another sheet, select a month from a drop down box above the table, and then for the table to auto-populate whether for each date and for each city it was a hit, miss or false alarm, by automatically entering either a H, M or FA in the cell. Again I'd like cities along the top and dates along the side.
I suppose there needs to be an IF formula (with some ISNUMBER statements too) checking whether cells are equal, more than or less than 0 or 1? Or is there a better way to do it, I've got no idea, so any help would be very much appreciated.
Hopefully that makes sense, I've attached a screenshot of the top of the spreadsheet for reference.
 

Attachments

  • Screenshot 2025-03-05 201018.png
    Screenshot 2025-03-05 201018.png
    14.3 KB · Views: 13
A slight update for that, look for this part of the code and add the blank entry. Please cross check the code in box. {Also you can try the formula above}
View attachment 123059
VBA Code:
If IsEmpty(forecastVal) Or IsEmpty(observationVal) Then
                        result = ""  ' Blank entry
                   
                    ElseIf IsNumeric(forecastVal) And IsNumeric(observationVal) Then
                        If forecastVal = 0 And observationVal = 0 Then
                            result = "H"
Thanks very much, it works :)
 
Upvote 0
If using your 365 version, would you be interested in a formula approach? Could probably be adapted if you need it to work in your 2021 version as well.
(This is a smaller data size but easily expandable to your full data ranges.)

drefiek2.xlsm
BCDEFGHIJ
5DateTypeLondonBerlinParisMadridAthensLisbonRome
61/01/2025Sunny Forecast0011011
7Observation1010011
82/01/2025Sunny Forecast0100100
9Observation1101101
103/02/2025Sunny Forecast110110
11Observation10001
124/02/2025Sunny Forecast001101
13Observation1010011
145/02/2025Sunny Forecast0100100
15Observation1101101
163/03/2025Sunny Forecast1100110
17Observation1011001
Sheet1


Cell A1 below would be the month drop-down.

drefiek2.xlsm
ABCDEFGH
1February
2
3LondonBerlinParisMadridAthensLisbonRome
43/02/2025HFAFAFAM
54/02/2025MHHFAHH
65/02/2025MHHMHHM
7
Sheet2
Cell Formulas
RangeFormula
B3:H3B3=Sheet1!D5:J5
A4:H6A4=LET(b,Sheet1!B6:B17,x,Sheet1!D6:J17,y,IF(x="",2,x),d,TOCOL(IF(b="",1/0,IF(TEXT(b,"mmmm")=A1,b,1/0)),2),q,MATCH(A1,TEXT(b,"mmmm"),0)+SEQUENCE(ROWS(d),,,2),HSTACK(d,IFNA(SWITCH(--(CHOOSEROWS(y,q-1)&CHOOSEROWS(y,q)),0,"H",1,"M",10,"FA",11,"H"),"")))
Dynamic array formulas.
Thanks a lot, a good solution as well, nice to have options!! Much appreciated!!
 
Upvote 0
If using your 365 version, would you be interested in a formula approach? Could probably be adapted if you need it to work in your 2021 version as well.
(This is a smaller data size but easily expandable to your full data ranges.)

drefiek2.xlsm
BCDEFGHIJ
5DateTypeLondonBerlinParisMadridAthensLisbonRome
61/01/2025Sunny Forecast0011011
7Observation1010011
82/01/2025Sunny Forecast0100100
9Observation1101101
103/02/2025Sunny Forecast110110
11Observation10001
124/02/2025Sunny Forecast001101
13Observation1010011
145/02/2025Sunny Forecast0100100
15Observation1101101
163/03/2025Sunny Forecast1100110
17Observation1011001
Sheet1


Cell A1 below would be the month drop-down.

drefiek2.xlsm
ABCDEFGH
1February
2
3LondonBerlinParisMadridAthensLisbonRome
43/02/2025HFAFAFAM
54/02/2025MHHFAHH
65/02/2025MHHMHHM
7
Sheet2
Cell Formulas
RangeFormula
B3:H3B3=Sheet1!D5:J5
A4:H6A4=LET(b,Sheet1!B6:B17,x,Sheet1!D6:J17,y,IF(x="",2,x),d,TOCOL(IF(b="",1/0,IF(TEXT(b,"mmmm")=A1,b,1/0)),2),q,MATCH(A1,TEXT(b,"mmmm"),0)+SEQUENCE(ROWS(d),,,2),HSTACK(d,IFNA(SWITCH(--(CHOOSEROWS(y,q-1)&CHOOSEROWS(y,q)),0,"H",1,"M",10,"FA",11,"H"),"")))
Dynamic array formulas.
How do I adapt the Sheet1!B6:B735 and Sheet1!D6:J735 parts of the LET formula so that they reference a cell containing a drop down list with the names of different sheets? Is it an INDIRECT formula perhaps, although I'm not sure exactly what it needs to be
 
Upvote 0
How do I adapt the Sheet1!B6:B735 and Sheet1!D6:J735 parts of the LET formula so that they reference a cell containing a drop down list with the names of different sheets? Is it an INDIRECT formula perhaps, although I'm not sure exactly what it needs to be
With the sheet name in, say, A2 try ..

drefiek2.xlsm
ABCDEFGH
1February
2Sheet1
3LondonBerlinParisMadridAthensLisbonRome
43/02/2025HFAFAFAM
54/02/2025MHHFAHH
65/02/2025MHHMHHM
7
Sheet2
Cell Formulas
RangeFormula
B3:H3B3=INDIRECT("'"&A2&"'!D5:J5")
A4:H6A4=LET(b,INDIRECT("'"&A2&"'!B6:B1000"),x,INDIRECT("'"&A2&"'!D6:J1000"),y,IF(x="",2,x),d,TOCOL(IF(b="",1/0,IF(TEXT(b,"mmmm")=A1,b,1/0)),2),q,MATCH(A1,TEXT(b,"mmmm"),0)+SEQUENCE(ROWS(d),,,2),HSTACK(d,IFNA(SWITCH(--(CHOOSEROWS(y,q-1)&CHOOSEROWS(y,q)),0,"H",1,"M",10,"FA",11,"H"),"")))
Dynamic array formulas.
 
Upvote 0
With the sheet name in, say, A2 try ..

drefiek2.xlsm
ABCDEFGH
1February
2Sheet1
3LondonBerlinParisMadridAthensLisbonRome
43/02/2025HFAFAFAM
54/02/2025MHHFAHH
65/02/2025MHHMHHM
7
Sheet2
Cell Formulas
RangeFormula
B3:H3B3=INDIRECT("'"&A2&"'!D5:J5")
A4:H6A4=LET(b,INDIRECT("'"&A2&"'!B6:B1000"),x,INDIRECT("'"&A2&"'!D6:J1000"),y,IF(x="",2,x),d,TOCOL(IF(b="",1/0,IF(TEXT(b,"mmmm")=A1,b,1/0)),2),q,MATCH(A1,TEXT(b,"mmmm"),0)+SEQUENCE(ROWS(d),,,2),HSTACK(d,IFNA(SWITCH(--(CHOOSEROWS(y,q-1)&CHOOSEROWS(y,q)),0,"H",1,"M",10,"FA",11,"H"),"")))
Dynamic array formulas.
Thanks very much it works!
 
Upvote 0
So, if you wanted a shorter vba approach you could use the features of the formula to do it without any looping.
Included in the code is an adjustment to check how many columns and how many rows are used in the relevant data sheet.

VBA Code:
Sub HMFA()
  Dim wsData As Worksheet
  Dim sMonth As String, DataRng As String
  Dim lr As Long, lc As Long
  
  With Sheets("Summary")
    sMonth = .Range("A1").Value
    Set wsData = Sheets(.Range("A2").Value)
    With wsData
      lr = .Range("C" & Rows.Count).End(xlUp).Row
      lc = .Cells(5, Columns.Count).End(xlToLeft).Column
      DataRng = .Range("D6").Resize(lr - 5, lc - 3).Address(0, 0)
    End With
    .UsedRange.Offset(2).ClearContents
    wsData.Range("D5").Resize(, lc - 3).Copy Destination:=.Range("B3")
    .Range("A4").Formula2 = Replace(Replace(Replace(Replace("=LET(b,INDIRECT(""'#'!B6:B%""),x,INDIRECT(""'#'!^""),y,IF(x="""",2,x),d," _
        & "TOCOL(IF(b="""",1/0,IF(TEXT(b,""mmmm"")=""@"",b,1/0)),2),q,MATCH(""@"",TEXT(b,""mmmm""),0)+SEQUENCE(ROWS(d),,,2)," _
        & "HSTACK(d,IFNA(SWITCH(--(CHOOSEROWS(y,q-1)&CHOOSEROWS(y,q)),0,""H"",1,""M"",10,""FA"",11,""H""),"""")))", _
        "#", wsData.Name), "%", lr), "^", DataRng), "@", sMonth)
    .Range("A4").SpillingToRange.Value = .Range("A4").SpillingToRange.Value
  End With
End Sub
 
Upvote 0
So, if you wanted a shorter vba approach you could use the features of the formula to do it without any looping.
Included in the code is an adjustment to check how many columns and how many rows are used in the relevant data sheet.

VBA Code:
Sub HMFA()
  Dim wsData As Worksheet
  Dim sMonth As String, DataRng As String
  Dim lr As Long, lc As Long
 
  With Sheets("Summary")
    sMonth = .Range("A1").Value
    Set wsData = Sheets(.Range("A2").Value)
    With wsData
      lr = .Range("C" & Rows.Count).End(xlUp).Row
      lc = .Cells(5, Columns.Count).End(xlToLeft).Column
      DataRng = .Range("D6").Resize(lr - 5, lc - 3).Address(0, 0)
    End With
    .UsedRange.Offset(2).ClearContents
    wsData.Range("D5").Resize(, lc - 3).Copy Destination:=.Range("B3")
    .Range("A4").Formula2 = Replace(Replace(Replace(Replace("=LET(b,INDIRECT(""'#'!B6:B%""),x,INDIRECT(""'#'!^""),y,IF(x="""",2,x),d," _
        & "TOCOL(IF(b="""",1/0,IF(TEXT(b,""mmmm"")=""@"",b,1/0)),2),q,MATCH(""@"",TEXT(b,""mmmm""),0)+SEQUENCE(ROWS(d),,,2)," _
        & "HSTACK(d,IFNA(SWITCH(--(CHOOSEROWS(y,q-1)&CHOOSEROWS(y,q)),0,""H"",1,""M"",10,""FA"",11,""H""),"""")))", _
        "#", wsData.Name), "%", lr), "^", DataRng), "@", sMonth)
    .Range("A4").SpillingToRange.Value = .Range("A4").SpillingToRange.Value
  End With
End Sub
Thanks, appreciated very much :)
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top