Just count visible Cells in Row Only

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hello, I have the following VBA that hides all columns notin the date range in A1-b1
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim dt As Range
  If Intersect(Target,Range("a1:b1")) Is Nothing Then Exit Sub
 Columns("c:jc").Hidden = False
   For Each dt InRange("c1:jc1")
    If dt.Value <[a1] Or dt.Value > [b1] Then Columns(dt.Column).Hidden = True
   Next dt
End Sub
In cell jd2 I want to just put in the formula to count thevisible cells with an “A” in. I havetried
=AGGREGATE(3,3,C2:JC2)
But this is giving me the overall total for the row, not justof the visible cells, how do I change the formula to ignore the hidden columns?
 
Last edited by a moderator:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You'll need a UDF.
 
Upvote 0

Forum statistics

Threads
1,215,239
Messages
6,123,816
Members
449,127
Latest member
Cyko

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