Using INDIRECT and COUNTA

DJWH

New Member
Joined
May 9, 2008
Messages
43
Hi,

I have the following formula

=COUNTA('4-6'!A:A)-1

where the worksheet name is '4-6'

However I want to use the INDIRECT function as I need to repeat this for multiple sheets and they all have different names based on a date. The date is in cell B2... and I thought the following would work:

=COUNTA(INDIRECT("'"&DAY(B2)&"-"&MONTH(B2)&"'!A:A)-1"))

However this brings the wrong value.

I have also tried:

=COUNTA(INDIRECT("'"&DAY(B2)&"-"&MONTH(B2)&"'!A:A)")-1)

This doesn't give the correct answer either.

Any idea of where I am going wrong?

Thanks
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
The minus 1 should be outside.
Code:
=COUNTA(INDIRECT("'"&DAY(B2)&"-"&MONTH(B2)&"'!A:A"))-1
 
Upvote 0
Hi

I think it might be easiest to write that like:

=COUNTA(INDIRECT("'" & TEXT(B2,"d-m") & "'!A:A"))-1
 
Upvote 0
Hi,

I have the following formula

=COUNTA('4-6'!A:A)-1

where the worksheet name is '4-6'

However I want to use the INDIRECT function as I need to repeat this for multiple sheets and they all have different names based on a date. The date is in cell B2... and I thought the following would work:

=COUNTA(INDIRECT("'"&DAY(B2)&"-"&MONTH(B2)&"'!A:A)-1"))

However this brings the wrong value.

I have also tried:

=COUNTA(INDIRECT("'"&DAY(B2)&"-"&MONTH(B2)&"'!A:A)")-1)

This doesn't give the correct answer either.

Any idea of where I am going wrong?

Thanks

Try...

=COUNTA(INDIRECT("'"&TEXT(B2,"d-m")&"!A:A"))-1
 
Upvote 0
Try...

=COUNTA(INDIRECT("'"&TEXT(B2,"d-m")&"!A:A"))-1

Thanks for your quick response however that doesn't bring the correct result either. I can get it to work by putting the COUNTA in the '4-6' sheet and just doing a direct reference using the INDIRECT function but that is more work.
 
Upvote 0
=COUNTA(INDIRECT("'" & TEXT(B2,"d-m") & "'!A:A"))-1 works now! Thanks :)

Out of interest, where was I going wrong with my attempt?

Just realised the above reply... so it was due to having the -1 outside the box? Thanks everyone!
 
Upvote 0

Forum statistics

Threads
1,214,397
Messages
6,119,273
Members
448,883
Latest member
fyfe54

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