Use ROWS() and COLUMNS() formulas to generate numbers in a sequence [quick tip]

Share

Facebook
Twitter
LinkedIn

Here is a quick excel formula tip to start your week.

Use ROWS() and COLUMNS() formulas next time you need sequential numbers.

What does ROWS() excel formula do?

ROWS excel formula takes a range as an argument and tells you how many rows are there in that range. For. eg. ROWS(A1:A10) gives 10.

How can you use ROWS() formula to generate sequential numbers?

Simple. Assuming you want to have the sequential numbers in range B1:B10, in B1 write =ROWS($B$1:B1) and copy down the formula in the range in B1:B10. You will now have sequential numbers in that range.

But this is lame. I could just enter the numbers myself.

You are right. Using the ROWS () to just generate sequential numbers is lame.

But in most scenarios, we need sequential numbers to do something else (like passing them to an INDEX or OFFSET formula). Often we use helper column with the sequential numbers to do this. But by using ROWS() formula, you can remove the need for helper column and easily scale your formulas.

See this example:

Actual question on PHD forums: Fill down a formula with increment

 Hi, I need help on filling a formula down with a constant increment. I would like the first cell to be ‘=+B1’ the next to be ‘=+B4’ the next to be ‘=+B7’ etc… so that the increment is 3. How can this be accomplished?

Actual answer using ROWS()

in Column C, write: =+offset($b$1,rows($C$1:C1)*3,0)) and copy down

There are lots of interesting uses for ROWS() formula.

Similarly, you can use COLUMNS() formula when your data is across columns.

PS: I just crossed my personal record for hard disk crashes in a week. Now my work laptop is on the bed too.

PPS: There are more than 100 posts on the PHD Forums already. Lots of interesting questions and answers to day to day excel problems.

PPPS: Posting will be thin this week. I have composed the next installment of project management and spreadcheats series during the weekend. But the posts are in the work laptop. So wait (and pray)

PPPPS: Have a fun week ahead. 🙂

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

One Response to “How to compare two Excel sheets using VLOOKUP? [FREE Template]”

  1. Danny says:

    Maybe I missed it, but this method doesn't include data from James that isn't contained in Sara's data.

    I added a new sheet, and named the ranges for Sara and James.

    Maybe something like:
    B2: =SORT(UNIQUE(VSTACK(SaraCust, JamesCust)))
    C2: =XLOOKUP(B2#,SaraCust,SaraPaid,"Missing")
    D2: =XLOOKUP(B2#,JamesCust, JamesPaid,"Missing")
    E2: =IF(ISERROR(C2#+D2#),"Missing",IF(C2#=D2#,"Yes","No"))

    Then we can still do similar conditional formatting. But this will pull in data missing from Sara's sheet as well.

Leave a Reply