Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:05,690 --> 00:00:11,360
In the previous couple of lessons, we've been taking a look at data validation, and we're going to
2
00:00:11,360 --> 00:00:18,050
finish out this section on data validation by taking it up a notch and looking at some of the types
3
00:00:18,050 --> 00:00:21,290
of things that you can do with custom data validation.
4
00:00:21,440 --> 00:00:27,950
And this does get a little bit complex, but it also gives me a chance to show you some functions that
5
00:00:27,950 --> 00:00:29,480
we haven't looked at yet.
6
00:00:29,690 --> 00:00:31,310
So what are we trying to do here?
7
00:00:32,180 --> 00:00:40,160
Well, I have an invoice number in Cell A7 and this invoice number and all invoice numbers that are
8
00:00:40,160 --> 00:00:47,900
going to be input into this spreadsheet must have two letters at the start, followed by four numbers.
9
00:00:48,710 --> 00:00:54,770
So we want to create a data validation role which checks the invoice number that's been entered into
10
00:00:54,770 --> 00:00:57,590
the cell to see if it meets these conditions.
11
00:00:57,830 --> 00:01:04,340
So two letters followed by four numbers, giving us an invoice number, which is six characters in total.
12
00:01:04,550 --> 00:01:07,580
So how can we do this using data validation?
13
00:01:07,820 --> 00:01:11,600
Let's jump up to data and go into validation.
14
00:01:12,470 --> 00:01:19,190
What we want to do here is we need to select custom because when we select custom, we can add a formula
15
00:01:19,190 --> 00:01:22,190
to this cell and that's exactly what we need to do.
16
00:01:22,220 --> 00:01:28,670
Here, we need to come up with a formula which is going to check the invoice number against these conditions.
17
00:01:28,940 --> 00:01:33,680
Now I could start typing the formula straight into this blank field just here.
18
00:01:34,190 --> 00:01:36,770
However, that isn't my preferred method.
19
00:01:37,430 --> 00:01:42,770
The problem with type in a formula into here, and I'll just show you an example with an F is that you
20
00:01:42,770 --> 00:01:46,070
don't actually get to see the function arguments underneath.
21
00:01:46,550 --> 00:01:51,830
And me personally, when I'm putting together a formula, particularly a more complex one, I like to
22
00:01:51,830 --> 00:01:53,540
be able to see those arguments.
23
00:01:54,230 --> 00:02:01,040
So I like to construct the formula in the worksheet first of all and then copy it into that formula
24
00:02:01,040 --> 00:02:03,590
field in that data validation area.
25
00:02:03,890 --> 00:02:07,020
And the formula that we need for this is quite a long one.
26
00:02:07,040 --> 00:02:11,240
So we're going to break it down so you understand exactly what we're doing.
27
00:02:11,450 --> 00:02:13,280
What do we need to do first here?
28
00:02:13,940 --> 00:02:18,020
Well, what do I know about the invoice number that's going to go into this cell?
29
00:02:18,620 --> 00:02:26,000
Well, I know it has to be six characters long, so I'm just going to type lengths of number just above,
30
00:02:26,300 --> 00:02:32,180
and I'm going to put a formula into this cell, which is going to tell me what the length of that value
31
00:02:32,180 --> 00:02:35,450
is, and we're going to use the LEN function to do that.
32
00:02:35,450 --> 00:02:41,360
It only has one argument, and that is whenever the invoice number is located, let's hit enter.
33
00:02:42,260 --> 00:02:48,440
So this is telling me how many characters I have in the value in Cell A7 now for the type of formula
34
00:02:48,440 --> 00:02:50,280
that I want to construct here.
35
00:02:50,300 --> 00:02:54,200
I need these calculations to produce true or false results.
36
00:02:54,440 --> 00:02:54,710
So what?
37
00:02:54,710 --> 00:03:01,010
I'm basically going to do here to get this to display true or false instead of the number six is I'm
38
00:03:01,010 --> 00:03:06,440
going to basically turn this into a logical formula in the formula bar and we're going to say equal
39
00:03:06,440 --> 00:03:07,100
to six.
40
00:03:08,920 --> 00:03:13,990
So the formula is going to grab the number of characters in the string and then it's going to test it
41
00:03:13,990 --> 00:03:19,930
and see if it's equal to six, if it is, it's going to give me a true result if I was to add another
42
00:03:19,930 --> 00:03:20,860
character onto the end.
43
00:03:21,160 --> 00:03:23,050
It's going to give me a false result.
44
00:03:23,680 --> 00:03:28,810
So now I have the true or false argument that I need for the first part of this formula.
45
00:03:28,990 --> 00:03:30,470
The next part of the formula?
46
00:03:30,490 --> 00:03:32,410
Well, let's take a look at what we need here.
47
00:03:32,980 --> 00:03:37,540
We want to check that the first two characters in the invoice number are letters.
48
00:03:38,290 --> 00:03:43,180
So let's say here first to characters letters.
49
00:03:44,410 --> 00:03:47,110
Now, how do we extract characters from a string?
50
00:03:47,620 --> 00:03:49,140
Well, we did this previously.
51
00:03:49,150 --> 00:03:51,460
We can use the left function.
52
00:03:51,820 --> 00:03:56,830
I want to extract from this piece of text and we want the first two characters.
53
00:03:57,490 --> 00:03:58,300
Let's enter.
54
00:03:59,110 --> 00:04:02,530
So again, this is going to extract the characters in this case.
55
00:04:02,560 --> 00:04:03,420
See B.
56
00:04:04,030 --> 00:04:07,960
But again, I need a true or false result in here.
57
00:04:08,140 --> 00:04:10,420
So what I'm going to do is something a little bit different.
58
00:04:10,420 --> 00:04:18,430
We're going to go up to the formula bar and we're going to use the function is no, I'm going to wrap
59
00:04:18,430 --> 00:04:20,920
that around the left function.
60
00:04:21,760 --> 00:04:27,160
And what this basically does is it looks at what we have in the cell and it says, is it a number true
61
00:04:27,190 --> 00:04:27,910
or false?
62
00:04:28,120 --> 00:04:31,930
So this is telling me that the first two characters are not numbers.
63
00:04:32,230 --> 00:04:33,570
Now let's just test this.
64
00:04:33,700 --> 00:04:40,660
If I was to change the first two characters to one and two, that should change to false, but it's
65
00:04:40,660 --> 00:04:41,170
not.
66
00:04:41,350 --> 00:04:43,450
So there's something not quite right.
67
00:04:43,450 --> 00:04:44,020
Just here.
68
00:04:44,800 --> 00:04:46,600
Let's put this back to UCB.
69
00:04:48,280 --> 00:04:53,650
Now, if we go in and evaluate this formula, we're going to be able to see what's wrong with this formula.
70
00:04:53,800 --> 00:04:59,050
So what I'm going to do here is I'm going to evaluate this formula and just quickly step through it.
71
00:04:59,800 --> 00:05:03,970
So let's click on Evaluate and I can see what the problem is.
72
00:05:04,690 --> 00:05:09,970
So where we have the actual invoice number, but notice that it's in quote marks.
73
00:05:10,630 --> 00:05:14,890
So that means that Excel actually thinks this number is text.
74
00:05:15,100 --> 00:05:20,230
So we need to add another little function, which will convert text to a value.
75
00:05:21,010 --> 00:05:25,630
So I'm going to click after is no, I'm going to use the value function.
76
00:05:25,660 --> 00:05:28,060
Let's hit, enter and see what we get.
77
00:05:28,810 --> 00:05:30,670
Well, we're getting false.
78
00:05:30,700 --> 00:05:39,100
Now, this should be a true if I go to this invoice number and if I change this to numbers instead of
79
00:05:39,100 --> 00:05:42,070
letters, it then goes to true.
80
00:05:42,580 --> 00:05:46,990
So it's kind of doing the opposite of what I want it to do at the moment.
81
00:05:47,230 --> 00:05:53,140
So what I'm going to do is I'm going to go up to my formula and we're going to add a knot function in
82
00:05:53,140 --> 00:05:53,500
front.
83
00:05:54,250 --> 00:05:56,350
And this is another logical formula.
84
00:05:56,380 --> 00:06:00,880
And this is basically going to get it to flip around and do the opposite of what I want it to do.
85
00:06:01,360 --> 00:06:03,850
And now we have another true condition.
86
00:06:03,850 --> 00:06:09,790
We're kind of aiming for all of these to be true when the invoice number is correct.
87
00:06:10,030 --> 00:06:14,100
So now all we need to do is very similar to what we've done previously.
88
00:06:14,110 --> 00:06:17,410
We just don't need to add the knock condition for the last one.
89
00:06:18,220 --> 00:06:20,800
So we're going to extract the last four numbers.
90
00:06:21,760 --> 00:06:24,130
Let's type in equals, right?
91
00:06:25,550 --> 00:06:32,270
A text is in cell eight seven, and we want the last four characters, as you might expect, that's
92
00:06:32,270 --> 00:06:36,890
going to give us eight eight, six five, so I'm going to go straight up to that formidable.
93
00:06:37,340 --> 00:06:43,160
We're going to say is the number and we're going to convert it to a value.
94
00:06:44,130 --> 00:06:47,610
Let's make sure we close off as many brackets as we've opened.
95
00:06:49,380 --> 00:06:51,330
And now we're getting a true result.
96
00:06:51,420 --> 00:06:56,580
So before we copy this formula across to data validation, let's just make sure that these are working
97
00:06:56,580 --> 00:06:57,180
correctly.
98
00:06:57,960 --> 00:07:05,010
So the length of what we type in should be six characters if we type in additional character that switches
99
00:07:05,010 --> 00:07:07,110
to false, which is incorrect.
100
00:07:10,190 --> 00:07:18,170
The first two characters should be letters, so if we change these to numbers that will switch to false,
101
00:07:18,170 --> 00:07:24,620
which is incorrect, so we're looking good so far, the last four should be numbers.
102
00:07:24,620 --> 00:07:30,020
So if I change these two letters, that one is going to switch to false.
103
00:07:30,290 --> 00:07:33,580
So I can see the outside of this data validation.
104
00:07:33,590 --> 00:07:35,420
This is all working, OK?
105
00:07:35,540 --> 00:07:41,540
So what I basically need to do is take the three formulas that I've created and combine them together,
106
00:07:42,200 --> 00:07:45,200
and I'm going to do that using an end function.
107
00:07:45,350 --> 00:07:48,080
Now we've got quite a bit of copying and pasting to do so.
108
00:07:48,090 --> 00:07:52,600
I'm going to open up the clipboard and get that to do a lot of the hard work.
109
00:07:52,610 --> 00:07:54,650
So I'm going to double click on the first formula.
110
00:07:54,950 --> 00:08:01,820
Let's select it, but don't select the first equals control C to copy it to the clipboard.
111
00:08:02,960 --> 00:08:06,690
Let's double click and let's copy the second formula.
112
00:08:06,710 --> 00:08:09,440
Control C to copy it to the clipboard.
113
00:08:10,460 --> 00:08:11,840
Let's double click again.
114
00:08:12,110 --> 00:08:14,310
Select the third formula.
115
00:08:14,330 --> 00:08:16,970
Control C to copy it to the clipboard.
116
00:08:18,020 --> 00:08:23,060
So now that I have these in there, it's going to be very simple for me to combine them all together
117
00:08:23,090 --> 00:08:24,380
using an end.
118
00:08:25,340 --> 00:08:34,970
So we want the first one comma, then the second one comma, then the third one close up another bracket
119
00:08:35,360 --> 00:08:38,350
hit enter and a formula isn't producing an error.
120
00:08:38,360 --> 00:08:40,010
So I think this looks pretty good.
121
00:08:40,970 --> 00:08:44,810
Now that we have this big, long formula in the formula bar.
122
00:08:45,080 --> 00:08:50,330
We can copy it from here and now we can add add data validation.
123
00:08:51,260 --> 00:08:53,060
So let's click on the cell.
124
00:08:54,280 --> 00:08:55,900
Up to date validation.
125
00:08:56,410 --> 00:09:02,300
And this time we're going to go to custom and we're going to control V to paste that formula in.
126
00:09:02,830 --> 00:09:03,640
Let's click on.
127
00:09:03,910 --> 00:09:09,820
OK, so now that we've done that, we can get rid of all of our calculation cells.
128
00:09:10,780 --> 00:09:16,510
So if somebody was to now come to here and enter in an invoice number that wasn't valid, we should
129
00:09:16,510 --> 00:09:17,770
get an error message.
130
00:09:17,980 --> 00:09:24,670
So if I was to enter a one two three four five six, that's not valid.
131
00:09:24,730 --> 00:09:29,830
Firstly, it's too long and I only have one letter at the beginning.
132
00:09:30,130 --> 00:09:35,110
What about if I enter something like K L eight nine zero one?
133
00:09:35,860 --> 00:09:39,280
That one's absolutely fine because it meets all of the conditions.
134
00:09:40,150 --> 00:09:45,400
What about if I was just to add some random numbers on the end, I'm going to get an error message again.
135
00:09:45,940 --> 00:09:51,670
And of course, if you wanted to, you could set up your own custom alert, custom warning and custom
136
00:09:51,670 --> 00:09:52,480
error message.
137
00:09:52,660 --> 00:09:56,200
Now that formula is really long and pretty complicated.
138
00:09:56,200 --> 00:09:59,590
We've introduced quite a few different functions in that.
139
00:10:00,220 --> 00:10:03,100
And if it is a bit too much at this stage, don't worry about it.
140
00:10:03,130 --> 00:10:09,460
I just wanted to show you something a little bit more complex and also get you working with some formulas
141
00:10:09,460 --> 00:10:10,570
that you're not familiar with.
14213
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.