Hello, guys, and welcome back to our requests of our course about the complete introduction to Vehbi
with Microsoft Excel.
So in today's class, we are still going to learn some tips and tricks that you guys can use basically
to be able to program with VBA.
So you'll see learn some pretty cool things, in my opinion.
What's left to learn?
It's not that complicated, but it can help you out.
So what I want to teach you today is basically how you can clear some cells.
So let's say, for example, you have I don't know if you have things inside of a cell.
So here, I'll just write down a text and I'll write down text on all those cells.
And basically, I want to clear some of those cells.
And to be able to do this, I will need to use Imakura.
Well, I can do it with the use of the delete button, but I prefer writing the only macro that will
basically delete one part of the text.
So that's exactly what we're going to do today.
We're going to learn how to delete things.
Also, we are going to learn how to basically change the name of the sheets that you guys have right
there.
And this is like a little bonus in my opinion.
This could be something really cool.
Let's say, for example, we receive a report each and every day that contains around 20 sheets.
And you need to rename them the same way each and every day.
Well, basically, you can use a macro instead of changing their names each and every day.
So let's start.
All right.
So first of all, what I'm asking you to do is pretty simple.
Just create yourself a little thing like this.
And after that, we are going to go inside of our visual basics.
So when we're on our visual basics, like always what we're going to do, we are going to create a new
module for our micro, as always, simply go in, insert into insert a new module.
Once it's done, we should have a blank page and from now on, what want to do.
So as always, we're going to insert a procedure because we are going to write down eight macros.
So we need to use a sub procedure.
So we're going to create a procedure and we're going to call it.
So we'll give it a name.
Let's name it.
So let's make it clear.
So right now we have our procedure and now let's say we want to basically delete some elements that
are right there.
So what I want to do, I don't want to delete all the cells.
I really want to I really want to select cell by cell the cells that I want to delete.
And this is basically exactly what we are going to do to it.
So pretty simple how exactly do delete some of the cells.
So honestly, it's just a simple line of code.
So the first thing we are going to select the range that we want to delete.
So we write down our range function.
And here we're going to write down what we want to delete.
So in this case, let's say we want to delete the five.
So this cell right there.
And basically, the only thing that we need to right after that is simply clear.
So here we go.
And now if we are up, what's going to happen is that, as you can see, the five have been deleted.
So what we can do as well is pretty simple.
We can basically write down all the cells that we want to delete and simply make a list of them.
And as you can see, it's going to be pretty simple to do so.
It's one of the five.
You want to delete E seven?
We want to delete EF three.
And they want to delete, I don't know, age six and we want to delete, let's say I know.
So what we'll do right now is pretty simple.
We're just going to run everything.
And as you can see, we have deleted all the cells that we wanted to ask.
Can see it's a really simple line of code, but it can be really useful in the case that you guys need
to delete some elements.
So it's not usually you don't use the clear the clear bottom because you can just click on delete.
But sometimes, let's say, for example, instead of repeating the same task again, again, again and
again on a lot well, on huge folders.
Let's say, for example, you know, that you want to delete some cells in particular each and every
day.
Well, you can create yourself a simple map to be able to do so.
All right, great.
So this is for the first microbe that we are going to learn today.
So the first thing the second thing that I want to teach you guys to do is actually pretty simple.
And once again, this is a bonus.
So I thought about it a little bit earlier today.
And basically, in my opinion, it's important to know how to change the name of your sheets.
So I teach at the beginning of the class how you can save your document with the use of macros, how
you can create.
Well, a lot of things with the use of macros.
But basically, I didn't show you how you can change the name of your sheet directly by coding, basically
by writing down a code that will allow you to do so.
So basically, this is exactly what we are going to do today.
So we are going to create a code.
Well, very simple code that what it will do, it will change the name of this sheet and the name of
this sheet as well at the same time.
So you'll see it's pretty simple and it works pretty much the same way as when we're working with simple
cells.
So what I will do, I will simply delete everything that we have right there.
So here in the last sheets, I have all the other projects that we have.
So basically I have those projects right there.
So pretty simple.
All right.
So let's try and do it.
So first thing that I will do, I will just create myself another module.
So once again, what you guys can do is simply click on insert and insert another module or simply delete
the other macro that we have created.
So when you have created another module, what we are going to start with is pretty simple.
We're going to start out to start out with a procedure.
So this is how we are starting now.
So here we are going to call it ringin.
Cheat's.
Great.
So we have our well, basically we have our document right here where our Michael and we are going to
start the creation of our well, the name changing of our sheets.
So pretty simple.
The first thing that we want to change will be the active sheet in which we are right now.
So let's say we are on our sheet number tonight.
So we're going to start out with this sheet.
So pretty simple.
Do we want to change the name of the sheet?
Let's say you want to change its name as well.
So we want to change the name of the sheet are active sheet, the sheet seven and the sheet eight.
So we're going to write it down.
So pretty simple.
How exactly do we change its name?
So we're going to select the active sheet and what exactly we want to change.
So we want to change the name.
So here we go.
Will write the name and there let's say we want to change our sheet number nine for project.
No.
Then so we change the name of our sheet, no, then then what will be the next step?
Next step will be going to sheet number seven, jumping right there to be able to change its name.
So this is exactly what we'll.
So how exactly we can change?
Well, how exactly we can do this jump.
So it's pretty simple.
We're going to use the select function in this case.
So we're going to write down sheets because we want to work with our sheets and for our sheets where
exactly what we want to go to sheet number seven.
So we'll just write it down.
So here will go to sheet number seven.
Sragow.
So when we are at that number seven, the next thing that we want to do is simply changing its name
as well.
And the how exactly do this I forget a little step right there.
So we said that I forgot is the so basically I need to select my sheet number seven.
Here we go.
Great.
So I have selected my sheep number seven now the next thing is pretty simple, we want to change its
name, so we are going to use the same function as the function that we used a little bit earlier.
So we're going to select the active sheep.
So basically right now, since we're at sheep number seven, active sheep is sheep number seven, but
instead we're going to change to change its name for Project seven.
Great.
So when you tell them what to do, we simply want to jump to seat number eight and do the exact same
thing.
So what we can do, instead of writing it down again, we can just copy everything and pass it right
there.
So instead of using sheet seven, we're going to use eight.
And instead of having project seventh year, we're going to have Project eight.
So pretty simple.
So we'll do right now we are simply going to see if the code works.
Well, we're going to look at the code instituted in mistake so I can see no mistakes for now.
So we'll do right now is pretty simple.
We're just going to try out our code to see if it works fine.
So pretty simple.
We can run it right away.
And as you can see, we change the name of our sheet to basically sheet number seven became Project
Seven.
Our active sheet became sheet nine, Project nine.
So here we have Project Seven, you have Project eight.
And basically we changed the name of all our sheets simply with the use of only one macro.
Of course, if you want to rerun it, it's not going to work because the sheet seven inch sheet eight
doesn't exist anymore.
So if we try it out, as you can see, it doesn't work, which makes a lot of sense.
So as you can see, it's pretty simple to understand.
So right now, if you let's say you guys receive a report or anything that you need to put in a certain
format each and every day, you can feed yourself a macro to be able to do so.
So you can see it's pretty simple to do.
So to summarize what we saw in this class, pretty simple.
We saw how you guys can clear some cells or a set of cells with the use of just one vehicle and how
you can change the name of the sheets on which you guys are working.
So that's at first class guys in our next class.