Learn Excel 17
Learn Excel 17
461
Fig. 809
Fig. 810
Part
III
462
Fig. 811
The formula in A2 is =IF(C2=C1,1+A1,1). In plain language, this formula says, If the customer in C is equal to the customer above me, then
add 1 to the cell above me. Otherwise, start at 1.
Result: Each group of customer invoices is numbered from 1 to N, as
shown in Fig. 812.
Fig. 812
463
Fig. 813
Part
III
463
Fig. 813
Part
III
=IF(C3=C2,A2,1+A2)
In plain language, this formula says, If the customer on this row equals
the row above, then use the group number on the row above. Otherwise,
add one to the group number above. Copy this formula down to all the
other rows, as shown in Fig. 814.
Fig. 814
Result: The records are all assigned a group number. Each customer
has a unique group number.
In order to allow future sorting, copy the formulas in column A and use
Paste Special Values to convert the formulas to numbers.
Summary: Use the IF function to add a group number to each group of
records.
Functions Discussed: =IF()
LEARN EXCEL FROM MR EXCEL
464
465
Part
III
Fig. 815
Strategy: Your goal is to get the data back into one row per record. This
process is possible. The process involves adding two new columns, one
called Group number and one called Sequence.
1)
First, add a new Row 1. Insert two new columns A and B. Add
headings as shown in Fig. 816 in A1:C1. The headings should be
Group, Sequence, and Text.
Fig. 816
2)
Fig. 817
466
467
3)
Part
III
Fig. 818
Sequence 1 record.
4)
5)
Sort the data by the Sequence number in column B. Your data will
look like Fig. 819.
Fig. 819
6)
Select cells C2:C7. From the menu, select Data Text to Columns.
Select Fixed Width and Next, as shown in Fig. 820.
468
469
Fig. 820
7)
Fig. 821
Part
III
8)
Choose the heading for each column and define a data format. You
dont really need the word ACCT each time, so choose to Skip the
first, third, and fifth fields. Make the sixth field a date. When your
information looks like Fig. 822, choose Finish.
Fig. 822
9)
Fig. 823
470
471
10) Next, select A8:C13. Cut and paste in F2. Add headings in F1:H1 of
Group, Seq, and Total, as shown in Fig. 824.
Fig. 824
11) Select H2:H6 and choose Data Text to Columns. In Step 1, select
Fixed Width and choose Next. In Step 2, Excel offers to split your
data into three fields. There is no need to have one column for the
word Invoice and another column for the word Total. As shown in
Fig. 825, double-click the line between Invoice and Total to delete
the line.
Fig. 825
Part
III
Fig. 826
13) In Step 3, choose to skip the field with Invoice Total and choose
Finish, as shown in Fig. 827.
Fig. 827
472
473
Fig. 828
15) Copy them to I2. The headings in I1:K1 are Group, Seq, and Name,
as shown in Fig. 829.
Part
III
Fig. 829
Fig. 830
You now have all the fields, one line per record. You also have the words
Group and Sequence taking up about five columns each. Before you delete the Group and Sequence columns, lets make sure that everything
worked correctly. The Group numbers in columns A, F, I, L, and O should
all match.
19) As shown in Fig. 831, in a blank column at the end, enter a large
AND function as shown below. Copy this formula down to all
rows:
=AND(A2=F2,F2=I2,I2=L2,L2=O2)
Fig. 831
20) A value of True means that you have successfully put all of the
Group 1 records back together. To test if all of the rows have True,
enter the formula =AND(R2:R99) in cell R1. As shown in Fig. 832,
if this formula is True, then youve crosschecked that all of the rows
match up.
Fig. 832
474
475
21) At this point, you can delete the columns that you dont need. As
shown in Fig. 833, delete columns R, P, O, M, L, J, I, G, F, B, and
A.
Fig. 833
Fig. 834
Part
III
Fig. 835
Strategy:
1)
Fig. 836
476
477
=IF(LEFT(C2,4)=Acct,MID(C2,6,5),A1)
2)
Enter this formula into cell A2 and copy it down through column
A.
As shown in Fig. 837, as you copy this formula down, it does the job.
In cell A2, the IF condition is true and data is extracted from C2.
In cell A3, the condition is not true, so the value from A2 is used.
Down in cell A7, a new customer number is found so the data from
C7 is used in A7. Cells A8 through A59 get the customer number
from A7.
Fig. 837
Part
III
You can use a formula of =MID(C2,12,50) to skip the first 11 characters and return the next 50 characters of the customer name.
However, this formula will add spaces to the end of the customer
name to ensure that you have 50 characters in the result. You really dont want all of those trailing spaces. The =TRIM() function
will remove leading and trailing spaces from text.
=IF(LEFT(C2,4)=Acct,TRIM(MID(C2,12,50)),B1)
3)
Enter this formula into cell B2 and copy it down through column
B.
Fig. 838
478
479
You have now successfully filled in account and customer. You need
to change these formulas to values.
4)
The last task is to remove all of the customer heading rows. As you
look for a method to isolate the heading rows, you will notice that
heading rows are the only rows with blank cells in column D. You
can move the blanks to the end of a dataset by sorting the data by
column D.
5)
Select the heading in D1. Hit the AZ sort button to sort ascending
by Date. Any rows without a value in column D will automatically
sort to the bottom of the dataset, as shown in Fig. 839.
6)
From D1, press the End key and then the Down Arrow key twice.
The cell pointer will be located on the first customer heading. Delete all of the rows below row 564.
Fig. 839
Part
III
Fig. 840
Fig. 841
480