If you look at the picture above. The thing I want is to run an formula when the text like 1ST or CUCA or 2ND occurs in column E. I want the formula +countif to run, but in this formula I define the range which is in the example F2:F25, but this depends on how many agents I have. If there is one agent less it needs to adapt the range.
Then I have the next day in this sheet and I need it to do the same thing but again with another range.
Can someone help me?
For the moment I use this but I defined the range but the range can change and I don't want to modify the code constantly
Sub Runcode()
    Dim strFormulas(1 To 6) As Variant    
    Range("F26").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R2C1,R[-24]C:R[-1]C)"
    
    Range("F27").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R5C1,R[-24]C:R[-1]C)"
        
    Range("F28").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R3C1,R[-24]C:R[-1]C)"
    
    Range("F29").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R4C1,R[-24]C:R[-1]C)"
    
    Range("F30").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R7C1,R[-24]C:R[-1]C)"
    
    Range("F31").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R6C1,R[-24]C:R[-1]C)"
    
    Range("F57").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R2C1,R[-24]C:R[-1]C)"
    
    Range("F58").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R5C1,R[-24]C:R[-1]C)"
        
    Range("F59").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R3C1,R[-24]C:R[-1]C)"
    
    Range("F60").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R4C1,R[-24]C:R[-1]C)"
    
    Range("F61").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R7C1,R[-24]C:R[-1]C)"
    
    Range("F62").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R6C1,R[-24]C:R[-1]C)"
    
    Range("F88").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R2C1,R[-24]C:R[-1]C)"
    
    Range("F89").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R5C1,R[-24]C:R[-1]C)"
        
    Range("F90").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R3C1,R[-24]C:R[-1]C)"
    
    Range("F91").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R4C1,R[-24]C:R[-1]C)"
    
    Range("F92").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R7C1,R[-24]C:R[-1]C)"
    
    Range("F93").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R6C1,R[-24]C:R[-1]C)"
    
    Range("F119").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R2C1,R[-24]C:R[-1]C)"
    
    Range("F120").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R5C1,R[-24]C:R[-1]C)"
        
    Range("F121").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R3C1,R[-24]C:R[-1]C)"
    
    Range("F122").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R4C1,R[-24]C:R[-1]C)"
    
    Range("F123").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R7C1,R[-24]C:R[-1]C)"
    
    Range("F124").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R6C1,R[-24]C:R[-1]C)"
    
    Range("F150").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R2C1,R[-24]C:R[-1]C)"
    
    Range("F151").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R5C1,R[-24]C:R[-1]C)"
        
    Range("F152").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R3C1,R[-24]C:R[-1]C)"
    
    Range("F153").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R4C1,R[-24]C:R[-1]C)"
    
    Range("F154").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R7C1,R[-24]C:R[-1]C)"
    
    Range("F155").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R6C1,R[-24]C:R[-1]C)"
    
    Range("F181").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R2C1,R[-24]C:R[-1]C)"
    
    Range("F182").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R5C1,R[-24]C:R[-1]C)"
        
    Range("F183").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R3C1,R[-24]C:R[-1]C)"
    
    Range("F184").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R4C1,R[-24]C:R[-1]C)"
    
    Range("F185").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R7C1,R[-24]C:R[-1]C)"
    
    Range("F186").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R6C1,R[-24]C:R[-1]C)"
    
    Range("F212").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R2C1,R[-24]C:R[-1]C)"
    
    Range("F213").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R5C1,R[-24]C:R[-1]C)"
        
    Range("F214").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R3C1,R[-24]C:R[-1]C)"
    
    Range("F215").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R4C1,R[-24]C:R[-1]C)"
    
    Range("F216").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R7C1,R[-24]C:R[-1]C)"
    
    Range("F217").Select
    ActiveCell.Formula2R1C1 = "=+countbycolor(R6C1,R[-24]C:R[-1]C)"
        strFormulas(1) = "+countbycolor(R2C1,R[-24]C:R[-1]C)"
        strFormulas(2) = "+countbycolor(R5C1,R[-24]C:R[-1]C)"
        strFormulas(3) = "+countbycolor(R3C1,R[-24]C:R[-1]C)"
        strFormulas(4) = "+countbycolor(R4C1,R[-24]C:R[-1]C)"
        strFormulas(5) = "+countbycolor(R7C1,R[-24]C:R[-1]C)"
        strFormulas(6) = "+countbycolor(R6C1,R[-24]C:R[-1]C)"
        
        Range("F26:AG31").FillRight
        Range("F57:AG62").FillRight
        Range("F88:AG93").FillRight
        Range("F119:AG124").FillRight
        Range("F150:AG155").FillRight
        Range("F181:AG186").FillRight
        Range("F212:AG217").FillRight
    Range("A2").Select
    ActiveCell.FormulaR1C1 = "1ST"
    Range("A3").Select

 
     
    
