00:00.0
00:04.2
Hey, This is Puneet back again and this video is going to be
00:04.3
00:09.1
interesting in so many ways. So we are gonna learn how we can use a VBA
00:09.2
00:14.0
code to hide or unhide the status bar, or how we can show
00:14.1
00:18.9
a message on the status bar. So, first of all, I'm gonna open the Developer Tab and I'm gonna
00:19.0
00:23.8
Click on the Visual Basic Editor to open it and then I'm gonna insert a new model
00:23.9
00:28.7
to use and from here I'm gonna start the code
00:28.8
00:33.6
[typing code]
00:33.7
00:38.5
So the first thing is to use the
00:38.6
00:43.4
application object and as well as you press
00:43.5
00:48.3
a dot.It gives you a list to select the properties so you need to select
00:48.4
00:53.2
Display Status Bar and here you
00:53.3
00:58.1
can use two different values False and True. So I'm gonna use False
00:58.2
01:03.0
here. Now this line of code tells VBA to
01:03.1
01:07.9
Hide the Status Bar. So application displays status bar equals
01:08.0
01:12.8
False and now if I run this code it simply hides
01:12.9
01:17.7
the Status Bar and now if I want status bar back I'm gonna use
01:17.8
01:22.6
True here. Application displays status bar equals True
01:22.7
01:27.5
that means to show the Status Bar and I fell on this code
01:27.6
01:32.4
it simply gives me Status Bar back. Alright!
01:32.5
01:37.3
So from here I'm gonna change the property
01:37.4
01:42.2
.Status Bar. Now I can you this property to
01:42.3
01:47.1
show a message (a custom message) on the Status Bar so I'm gonna use
01:47.2
01:52.0
equals again and then a message that I want to show
01:52.1
01:56.9
[typing code]
01:57.0
02:01.8
Alright! so I'm gonna run this code
02:01.9
02:06.7
as soon as I run this code it simply shows that message
02:06.8
02:11.6
which has been specified in the code on the Status Bar. Now, here is one thing that
02:11.7
02:16.5
you need to take care that when you show a message on the Status Bar using a VBA code it
02:16.6
02:21.4
will stay there untill or unless you clear that message so
02:21.5
02:26.3
to clear that message we need to run this code again but with the Blank Value.
02:26.4
02:31.2
So, Application.StatusBar equals a Blank Value
02:31.3
02:36.1
and when I run this code it simply gives me
02:36.2
02:41.0
the default status bar back
02:41.1
02:45.9
or you can also use False to come back to the default Status Bar if you already have
02:46.0
02:50.8
a message on that you can simply use False. Just like that.
02:50.9
02:55.7
Now, let's see an example where we can show a progress message on the
02:55.8
03:00.6
Status Bar. A progress message of a loop so for this I'm gonna
03:00.7
03:05.5
use a code. Now, in this code, we have a loop that will run from
03:05.6
03:10.4
1 to 10,000 times and show a progress message on the Status Bar. So, let's
03:10.5
03:15.3
understand this code line by line so in the first line here I'm using a
03:15.4
03:20.2
variable to store the count of the loop and
03:20.3
03:25.1
in the second line I'm using, actually, I'm starting a loop that will
03:25.2
03:30.0
loop from count 1 to 10,000 say in this line I'm using again
03:30.1
03:34.9
that Application.StatusBar and here we have a message that will show
03:35.0
03:39.8
the progress so it says x of 10,000 so basically x is the counter of the
03:39.9
03:44.7
loop and the format x/10,000 percent so this
03:44.8
03:49.6
the part will show the percentage of the progress and then a
03:49.7
03:54.5
closing loop and here I'm using those events to not to hang the
03:54.6
03:59.4
excel application so basically when you run a loop excel simply a freeze
03:59.5
04:04.3
everything untill that loop stop and here I'm using
04:04.4
04:09.2
the Application.StatusBar = False to clear that message in the end.
04:09.3
04:14.1
So make sure to have a look on the Status Bar because this progress
04:14.2
04:19.0
message will be there for a few seconds.
04:19.1
04:23.9
Now as you can see that progress that loop is running.
04:28.9
04:33.7
It will take quite a few seconds
04:33.8
04:38.6
Alright! wait 75%
04:38.7
04:43.5
85%, 95% and 100.
04:43.6
04:48.4
Now, here you need to note down the two most important points
04:48.5
04:53.3
that you always need to use Application object before using
04:53.4
04:58.2
Status Bar or display Status Bar property and you always need to
04:58.3
05:03.1
clear the message from the Status Bar using a code that means you
05:03.2
05:08.0
need to use Status Bar = False or a Blank Value to
05:08.1
05:12.9
clear the message. Hey, thanks for watching
05:13.0
05:17.8
this video and I hope you found this VBA trick useful and
05:17.9
05:22.7
make sure to subscribe to this channel because I will be coming out with lot of cool
05:22.8
05:27.6
and helpful VBA Tutorials in the coming weeks. So, make sure to hit
05:27.7
05:32.5
Subscribe Button and Like this Video and I will see you next week