Select Sheet & Countifs based on name in Column A

jconkl02

Board Regular
Joined
May 25, 2016
Messages
55
I'm creating a scorecard for employees based off of the tickets that they are working. I'm breaking the tickets worked by each employee into separate worksheets. The names of the worksheets will equal the name in Column A. On my main worksheet I'm calling SCORECARD I want to use COUNTIFS to go count the tickets that were worked that month by the person listed in Column A, but I can't figure out how to reference the worksheet name based off the name in Column A. So instead of typing this "Sheets("John Smith").Select" I want it to substitute "John Smith" with what ever value is in A (starting at A3). Likewise, instead of using this syntax for the countifs "=COUNTIFS('John Smith'!$B:$B,A2)", I want it to substitute "John Smith with what ever value is in A (starting at A3).
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
For worksheet formulas, use INDIRECT:

=COUNTIFS(INDIRECT("'"&A3&"'!$B:$B"),A2)

For VBA:

Sheets(Range("A3")).Select

although you usually don't need to select sheets in VBA, and it tends to slow down the macro. But that's the basic idea.
 
Upvote 0
Solution
For worksheet formulas, use INDIRECT:

=COUNTIFS(INDIRECT("'"&A3&"'!$B:$B"),A2)

For VBA:

Sheets(Range("A3")).Select

although you usually don't need to select sheets in VBA, and it tends to slow down the macro. But that's the basic idea.
Thank you Eric W. This works. I know I need to get out of the bad habit of using .select. I also use With Sheets/End With. Thanks for the assist.
 
Upvote 0

Forum statistics

Threads
1,215,831
Messages
6,127,142
Members
449,362
Latest member
Bracelane

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