COUNTIF Dynamic Range Formula

Gos-C

Active Member
Joined
Apr 11, 2005
Messages
258
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I have the following formula in cell EG1:

=COUNTIF$EG2:$EG550,"a")

but I need to use a dynamic range instead of the fixed range.

I tried:

=COUNTIF(OFFSET($EG2,0,0,COUNTA($EG:$EG),1),"a")

and

=COUNTA(OFFSET($EG2,0,0,MATCH(1E+306,$EG:$EG),"a")

but neither works.

Any help, please?

Thank you,
Gos-C
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
This may help if all cells are filled
=COUNTIF(INDIRECT("EG2:EG"&COUNTA(EG:EG)),"a")
 
Upvote 0
Maybe this

=COUNTIF($EG$2:INDEX($EG:$EG,MATCH(REPT("z",255),$EG:$EG)),"a")

HTH

M.
 
Upvote 0
Hi all,

I have the following formula in cell EG1:

=COUNTIF$EG2:$EG550,"a")

Maybe this

=COUNTIF($EG$2:INDEX($EG:$EG,MATCH(REPT("z",255),$EG:$EG)),"a")

HTH

M.
As written, that formula will produce a circular reference.

=COUNTIF(EG2:INDEX(EG2:EG65536,MATCH("zzzzz",EG2:EG65536)),"a")

However, I have to ask if a dynamic range is really necessary? Why do they need a dynamic range with a COUNTIF function?
 
Upvote 0
Thank you, Marcelo, id107 and T. valko.

Yes, I saw the circular reference; I move the formula to cell EH1.

=COUNTIF(INDIRECT("EG2:EG"&COUNTA(EG:EG)),"a") did not give the correct answer.

I perfer =COUNTIF($EG$2:INDEX($EG:$EG,MATCH(REPT("z",255),$EG:$EG)),"a").

I am using a dynamic range here because I also used it in column A to determine the data range.

With appreciation,
Gos-C
 
Upvote 0
Hi all,

I want to modify the following code to allow the user to select EG only if EE has PAID:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Cells.Count > 1 Then Exit Sub

        If Not Intersect(Target, Range("EG2:EG" & Cells(Rows.Count, 1).End(xlUp).Row)) Is Nothing Then

            Target.Font.Name = "Marlett"

                If Target = vbNullString Then

                    Target = "a"

                Else

                    Target = vbNullString

                End If
        End If

End Sub

Any help, please?

Thank you,
Gos-C
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,304
Members
452,904
Latest member
CodeMasterX

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