18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Part II<br />

Working with Formulas and Functions<br />

You can, of course, use the TRANSPOSE function to transpose an array stored in a range. The following formula,<br />

for example, uses an array stored in A1:C4 (four rows, three columns). You can enter this array formula<br />

into a range that consists of three rows and four columns.<br />

{=TRANSPOSE(A1:C4)}<br />

FIGURE 17.12<br />

Using the TRANSPOSE function to transpose a rectangular array.<br />

Generating an array of consecutive integers<br />

As you can see in Chapter 18, generating an array of consecutive integers for use in an array formula is<br />

often useful. The ROW function, which returns a row number, is ideal for this. Consider the array formula<br />

shown here, entered into a vertical range of 12 cells:<br />

{=ROW(1:12)}<br />

This formula generates a 12-element array that contains integers from 1 to 12. To demonstrate, select a<br />

range that consists of 12 rows and one column and enter the array formula into the range. You’ll find that<br />

the range is filled with 12 consecutive integers (as shown in Figure 17.13).<br />

If you want to generate an array of consecutive integers, a formula like the one shown previously is good —<br />

but not perfect. To see the problem, insert a new row above the range that contains the array formula. Excel<br />

adjusts the row references so that the array formula now reads<br />

{=ROW(2:13)}<br />

The formula that originally generated integers from 1 to 12 now generates integers from 2 to 13.<br />

For a better solution, use this formula:<br />

{=ROW(INDIRECT(“1:12”))}<br />

This formula uses the INDIRECT function, which takes a text string as its argument. Excel does not adjust<br />

the references contained in the argument for the INDIRECT function. Therefore, this array formula always<br />

returns integers from 1 to 12.<br />

CROSS-REF<br />

Chapter 18 contains several examples that use the technique for generating consecutive<br />

integers.<br />

326

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!