Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Power excel 2016 with mrexcel Master Pivot Tables, Subtotals, Charts, VLOOKUP, IF, Data Analysis in Excel 2010–2013 (Bill Jelen) (z-lib.org).pdf
Скачиваний:
4
Добавлен:
14.08.2022
Размер:
49.75 Mб
Скачать

88

POWER EXCEL WITH MR EXCEL

 

 

 

CONCATENATE SEVERAL CELLS

Problem: I have to concatenate several cells.

Strategy: The February 2016 release of Office 365 now offers TEXTJOIN and CONCAT functions. Both functions are able to accept a range of cells. CONCAT smashes all of the text together. TEXTJOIN allows you to specify text to go between each value and if Excel should ignore empty cells.

Figure 208 TEXTJOIN is a great addition to Office 365.

Gotcha: You have to be subscribing to Office 365 to access TEXTJOIN. If you have an earlier version of

Excel, download the free MoreFunc add-in and us MCONCAT.

JOIN TEXT WITH A DATE OR CURRENCY

Problem: I just learned about concatenation, and I’m trying to join text with currency and with a date. As you can see in cell B13, when I attempt to join both date and currency with text, the currency loses the dollar sign and the date appears as a strange number. What am I doing wrong?

Figure 209 The formula in B13 fails miserably.

Strategy: Excel internally stores dates as numbers and relies on the number format to display the number as a date. In the formula, you can use the TEXT function to convert a date or a number into text with a particular numeric format. For example, the formula =TEXT(F1+F3,”mm/dd/yyyy”) would produce the text 07/18/2014. Thanks to the variety of custom number formats, you could also use =TEXT(F1+F3,”dddd, mmmm d, yyyy”) to create the text Friday, July 18, 2014.

Additional Details: If you are not sure of the actual custom number format codes, you can query them from any existing cell. Here’s an example:

1. Select cell E11.

2. Press Ctrl+1 to display the Format Cells dialog.

PART 2: CALCULATING WITH EXCEL

89

 

 

3.Click the Number tab and then select the Custom category. Excel will show the actual code used to generate the format in that cell.

4.Highlight those characters, press Ctrl+C to copy to the Clipboard, and paste into the TEXT function.

5.Change the formula in B13 to

=“Please remit “&TEXT(E11,”$#,##0.00”)&

” before “&TEXT(F1+F3,”dddd, mmmm d, yyyy”)

Figure 210 Use the TEXT function to format dates and currency.

Additional Details: Excel stores dates as the number of days elapsed since January 1, 1900 (on a PC), or since January 1, 1904 (on a Mac). The 41838 shown in cell B13 of Figure 209 corresponds to July 18, 2014. While this is a fascinating bit of information (if you are Cliff Claven), I’ve never had a manager call and ask, “Hey, how many days after January 1, 1900, is that receivable due?” This method makes it easy for

Excel to calculate differences between two dates.

BREAK DATA APART USING FLASH FILL

Problem: Using LEFT, MID, RIGHT, FIND, and LEN makes my head hurt.

 

2

 

 

 

Figure 211 Formulas to split data, from a previous edition of this book.

Strategy: Excel 2013 introduced a new Flash Fill feature that simplifies this process.

Say you want to break out the left, center, or right portion of the account ID in column A. Add a heading above column B. Type a sample of what data you want to break out from column A. Select the blank cell under your sample. Press Ctrl+E to invoke Flash Fill. Excel will fill in the remaining values.

Figure 212 You need both the heading and the first sample for Flash Fill to work.

Flash Fill will use any of the columns in the current region. Press Ctrl+E from C3 and then from D3 and you will fill all three columns.

90

POWER EXCEL WITH MR EXCEL

 

 

Figure 213 After running Flash Fill in B3, C3, and D3.

Additional Details: Sometimes the first row of the data produces an ambigious example. For example, imagine if the part number was 999-999-999, Excel would not know if you wanted the first, second, or third segment. In this case, type an example in row 2, another example in row 3, and then Ctrl+E from B4.

Other times, there are two sets of rules that need to be applied. In the Figure below, you are trying to break out the first name from column A.

Figure 214 Type Gypsy, then press Ctrl+E from B3.

After applying Flash Fill, you can correct a later cell that represents the other rule. Type Mary Ellen in B4 and press Enter. Flash Fill will look for other examples of three names and fix those.

Figure 215 Correct one of the filled cells and Flash Fill will look for similar examples.

PART 2: CALCULATING WITH EXCEL

 

91

 

 

 

PARSE DATA USING TEXT TO COLUMNS

Problem: A vendor gave me a file that contains three- segment item numbers. The segments are separated by dashes. The FIND function makes my head hurt, but I need to break the part number into three columns. What do I do?

Figure 216 Split the item number at each dash.

Strategy: You can use the Text to Columns command on the Data tab to parse the item number. Follow these steps:

1.

Copy the item number to the right

 

 

 

side of your data in column F. The

 

 

 

Text to Columns command will fill

 

 

 

several columns to the right of the

 

 

 

original column. Make sure you

 

 

 

have plenty of blank columns.

 

 

2.

Select the entire range of data in

 

 

 

2

 

column F. Place the cell pointer

 

 

in cell F2. Press Ctrl+Shift+Down

 

 

3.

Arrow.

 

 

Select Data, Text to Columns. The

 

 

 

Convert Text to Columns Wizard

 

 

 

will work on either data that is de-

 

 

 

limited or on data that has a fixed

 

 

 

width to each segment.

 

 

4.

Because the data in this example

Figure 217 The dashes are known as delimiters.

 

is delimited by a dash, in step 1 of

 

 

 

the wizard, leave the radio button

 

 

5.

on the Delimited setting.

 

 

Click Next.

 

 

6.By default, step 2 of the wizard assumes that the data is delimited by a tab, so uncheck the Tab check box. Other standard choices are commas, spaces, and semicolons. Since dash is not in the list, you should choose the Other check box. In the Other text box, enter a dash. The Data Preview window will show the data in three columns.

7.Click Next.

Figure 218 Specify a dash in the Other box.

8.Click Next. In step 3 of the wizard, if desired, specify the data type of the columns. Unless you have dates, the General type is okay. Note that if you want to preserve any leading zeros in the second segment of the item number, you should choose the heading of that field and change it from General to Text.