I have a sheet called "A-LOG" and every day I use an excel VBA macro to take a snapshot of column A which has live alarm data, and pastes a copy of column A after the last column on the sheet with data in it. Over time I have a good indicator of daily alarms history. I also use a simple formula in column B to count how many alarms are found across each row's range of columns.
Existing formula: =COUNTIF(B4:BZJ4,"?*")
The problem is every few months or so I need to keep manually changing the last column text to expand the formula. I have the following VBA in my macro to find the last column in use and I added the bold text to now also paste that numeric value into the A-LOG sheet.
LastColumn = Sheets("A-LOG").Cells(1, Sheets("A-LOG").Columns.Count).End(xlToLeft).Column
Sheets("A-LOG").Range("Z1") = LastColumn
Then I found this formula that converts that numeric value into the text column name equivalent so I put that in Z2
Z2=SUBSTITUTE(ADDRESS(1, Z1, 4), "1", "")
Then I was thinking I could use INDIRECT to use in my count formula like:
=COUNTIF(B4:INDIRECT(Z$2&4),"?*")
Which does supply the correct count, but I can't copy this formula down the page as the 4 number doesn't change.
Maybe there is a more efficient solution or formula that could be used, but I do have about 15k rows so I do want to be mindful of calculation stress on the workbook.
Existing formula: =COUNTIF(B4:BZJ4,"?*")
The problem is every few months or so I need to keep manually changing the last column text to expand the formula. I have the following VBA in my macro to find the last column in use and I added the bold text to now also paste that numeric value into the A-LOG sheet.
LastColumn = Sheets("A-LOG").Cells(1, Sheets("A-LOG").Columns.Count).End(xlToLeft).Column
Sheets("A-LOG").Range("Z1") = LastColumn
Then I found this formula that converts that numeric value into the text column name equivalent so I put that in Z2
Z2=SUBSTITUTE(ADDRESS(1, Z1, 4), "1", "")
Then I was thinking I could use INDIRECT to use in my count formula like:
=COUNTIF(B4:INDIRECT(Z$2&4),"?*")
Which does supply the correct count, but I can't copy this formula down the page as the 4 number doesn't change.
Maybe there is a more efficient solution or formula that could be used, but I do have about 15k rows so I do want to be mindful of calculation stress on the workbook.