Counting Cells that come before and after a cell with specific text

camelrunner

New Member
Joined
Sep 9, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I'm working in macro-enabled workbook. The tab I'm working on "Direct" has data appearing from user input on the tab "Input". The user chooses the data on the Input tab to send to the Direct tab as an A or B. The data is then grouped with all the A selections and then all the B selections with the header cells containing "Data A Selection" and "Data B Selection" above the data. I need to count how many cells are between the A selection and the B selection. Additionally I then need to count the number of cells after the B selection header. Each data entry in the A and B selection are separated by a blank row, so I'm think I need the TRIM function. The issue I'm having is I can't search within in a fixed range because the number of A and B selections change based on the number of data values, so 1 user may have 5 A selections and 2 B selections and another user may have 1 A selection and 5 B selection.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
User 1.png

Input from User 1

User 2.png


Input from user 2

Route A will always start in A9 in the workbook, but Route B varies based on how many data samples are under Route A. I need to count how many data samples (#1-1, #1-2, #2-1, etc) are underneath Route A and Route B so I can have a cell off to the side that shows the total for Route A and another cell that shows the total for Route B. For User one the total would be Route A: 7 and Route B:2, User 2 would have Route A: 3 and Route B:1.
 
Upvote 0

Forum statistics

Threads
1,223,856
Messages
6,175,027
Members
452,604
Latest member
cballetti

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