简体   繁体   中英

Using INDIRECT() with INDEX() function

I have a formula which I am hoping to build on to be able to drag down to auto complete for a number of rows.

=COUNTA(INDEX(1:100,0,ROW(A1)))

The aim of this formula is to count the number of non blank cells in each of my columns. I am aware that I could use another formula...

=COUNTA(EIM!A$1:A$100)

... and drag this across, paste special values and then paste special transpose it, but I was wondering if there was another (more elegant) way. As you can see in the second formula, I am tring to pull the values of another worksheet. Therefore, I was thinking INDIRECT() being the way to go.

My question is: How can I use INDIRECT() to combine with my first formula that uses the INDEX() function to make this happen?

Below is a screenshot of current formula as it evaluates (not sure if it helps):

截图

Sure you could , but should you?

To do it, you'd use R1C1 style, by specifying false in indirect:

=COUNTA(INDIRECT("EIM!R1C"&ROW(A1)&":R100C"&ROW(A1),FALSE))

or just:

=COUNTA(INDEX(INDIRECT("EIM!$1:$100"),0,ROW(A1)))

Often, if you're using INDIRECT you're doing something wrong. The only reasonable use-cases for indirect I've seen are (a) choosing another worksheet by formula (for which there is no good way in Excel) and (b) writing an Excel tutorial example that references a named cell.

If you are always referencing a particular worksheet, you'd use:

=COUNTA(INDEX(EIM!$1:$100,0,ROW(A1)))

If each column represents a different worksheet, then indirect might be acceptable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM