2 Handy Methods to Count Columns Until a Value Is Reached in Excel

iIn terms of working with datasets, Excel is one of the most frequently utilized tools. It benefits us in a variety of ways. Here, In this piece, I’ll discuss techniques that you may use for your problem that is to count columns in Excel till a certain value is reached. That implies that I will use formulas to determine the number necessary to get at a given value.

📁 Download Excel File

The sample worksheet that we used during the discussion is available to download for free right here.

Learn to Count Columns Until a Value Is Reached in Excel with These 2 Handy Methods

If you are here that clearly states your involvement with Excel in professional or academic life or maybe you are in love with this beautiful creation of humans. While using Excel for any dataset you may need to Count the Columns and sometimes for advanced problems counting columns can be necessary until a certain value is reached. We have come up with a solution to your problem which is elaborated down below with brief discussion and explanation of every detail.

Method 1

1. Use of a Combined Formula

This paragraph will be demonstrating the use of a bunch of functions for the solution which includes COLUMNIF, MIN, OFFSET, SUBTOTALMATCH, and IFERROR and to count the columns until the desired value is reached. This may sound a bit complex if you are new to excel but we will recommend you go through the breakdown part which will certainly help you to understand the total process with ease.

⬇️⬇️ STEPS ⬇️⬇️

  • Firstly, Select cell G6.
  • Then jot the formula down below.

=IFERROR( MATCH( TRUE, SUBTOTAL( 9, OFFSET( D6, , , , COLUMN(D6:F6)-COLUMN(D6)+1))>=C6, 0)-MIN( IF(D6:F6<>””, COLUMN(D6:F6)-COLUMN(D6)+1))+1, “Target is Not Fulfilled”)

 excel count columns until value reached using combination of IFERROR, MATCH, SUBTOTAL, OFFSET, COLUMN, MIN functions

You will be in possession of a series of numbers when you enter the SUBTOTAL Function. These different numbers can handle different situations or different conditions based on the problem we are solving. Pick 9 as the thing we need is the Sum of these Numbers.

IFERROR, MATCH, SUBTOTAL functions formula for count columns until value reached

🔨 Formula Breakdown


➡️ This command will result in column number of cell D6

Out-turn: {4}

👉  COLUMN(D6:F6)

➡️ That will give you all the column numbers of the range. D6:F6

Out-turn: An array containing 4,5, and 6.

👉  IF(D6:F6<>””,COLUMN(D6:F6)-COLUMN(D6)+1)

➡️ The logical condition gives TRUE as all the results. The output of the function is the array containing 1,2, and 3.

👉  MIN(IF(D6:F6<>””,COLUMN(D6:F6)-COLUMN(D6)+1))

➡️ This command shall Identify the lowest value from those outputs. So in this case, it is {1}.


➡️ This reference determines how many rows down and how many columns are we shifting to the right from cell D6. The result of this portion in this particular scenario is an array containing three 250s.


➡️ This portion first evaluates the subtotal of them and checks if it is greater or equal to cell C6. This is FALSE in the first case and TRUE in the latter two. So it gives the outcome that way.


➡️ Illustrates the relationship between a value-matching item’s location in relation to other items which, in this case, is {2}.

👉 IFERROR(MATCH(….), “Target is Not Fulfilled)

➡️ Up until the previous portion, the formula ran successfully in this scenario. But it won’t always be the case. So the IFERROR function secures that we do not get an error value where the condition is not fulfilling. As the condition is not fulfilling is a valid scenario and indicates that the criteria is not met (causing the error), we added the string “Target is Not Fulfilled” in case the error is to occur.

  • Press the Enter key next. Excel is going to count columns until it obtains the value.

We have solved the problem as given in the workbook here. Here we are taking a look at a grocery store Sale Target of three months for different products in column C. Other columns represent the amount of sales that took place in these three different months for different specific products. So, we basically used Excel to count columns until the value reached the targeted sale. Let’s solve this problem with a different approach.

📕 Read More: Count One Column If Another Column Meets Criteria in Excel

Method 2

2. Combination of IF and SUM Functions

Here we’ll be using mainly the IF function with the help of the SUM function and create a formula to count the columns until we reach the value. This approach is quite easy if you understand the IF function. If you don’t you can simply click on the link reference that I’ve provided.

⬇️⬇️ STEPS ⬇️⬇️

  • First, select cell G6.
  • Now simply copy the formula written below.

=IF(D6>C6,1,IF(SUM(D6:E6)>C6,2,IF(SUM(D6:F6)<C6,”Target Not Fulfilled”,3)))

 excel count columns until value reached using IF function

  • Press Enter and you are good to go.

  • Simply copy this formula along the column for other results.

📕 Read More: Count One Column If Another Column Meets Criteria in Excel

📄 Important Notes

🖊️  Be careful while using the code as there are a lot of terms and if you lose concentration the code may be incorrect.

🖊️  As it’s a long code debugging is a big issue.

📝 Takeaway from This Article

📌  Here you have learned to use Excel to count the columns until a certain value.

📌  How to combine different functions to create a code.


Firstly, I hope you were able to use the techniques I demonstrated in this Excel Count Columns until Value Reached lesson. Moreover as you can see, there are a lot of options on how to do this decide deliberately on the approach that best addresses your circumstance. Moreover, I advise repeating the steps for clearing confusions. I’ve tried to detail the exact approach of Excel to count columns until a value for you. However I earnestly hope you can use it. Please share your experience with us in the comment box about how your experience was throughout the article and what we need to improve or add to make things better for you folks. If you encounter any issues yet again regarding Excel, spit it in the comment box. The Excelden crew is always available to answer your questions. Keep educating yourself by reading. Lastly for more Excel-related articles please visit our website Excelden.com.

Related Articles

(Visited 78 times, 1 visits today)


Hello there. I am Nashid, an Engineer. I Love music, traveling, sports and gaming. I have recently grown interest in DATA SCIENCE and wish to build a career over it. Excel is one of the greatest modern digital creation of human. Life simply gets easier. My Articles are meant to lead you to that easier life with efficiency. If you need any kind of help regarding my articles even anything else try contacting me on social platforms of which I've provided. Keep learning. Wish me luck and Thank you.

We will be happy to hear your thoughts

Leave a reply