Excel VBA - Font

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we'll see how to play with your font into your Excel using the macro part so for example playing with the font I'm trying to say you like if you have written some text into your cells and if you want to make it as bold italic underline or if you want to change the font name okay or if you want to do some underlining part or strikethrough anything you can do with help of this macro part though it is easy from here but if you want to automate that process how we can do with the help of macros so let us see that now if you see i'm using the same excel vba workbook okay which I've already created by the first session now I have created a sheet that is e underscore font okay now I will be writing a macro in that place in the VBA editor so I'll open this VBA editor now if you see I've created a underscore font module how do you create a module go to insert and click on this module and then you can rename that model part after I create a module it was earlier blank I have created a sub procedure font okay you can change the name instead of font 5 10 20 whatever name you want you can give it 110 120 I have written something as range a 1 to a 10 equal to totals so I have written some data some text into that because unless you have a text you cannot do the other part like bold italic underline you will not come to know next I'll go to the next line now I'll show you if you want to change the name of the font how do you do that okay but before that yeah so I'll just type as range a 1 to a 10 dot font now what exactly is dot font it is an object which is inside this object this is nothing but a cell a 1 to a 10 these are all cells in that cells obviously you'll have some text that is nothing but a font okay with that fun I'll just type here's dot what do you want to do with that font so do you want to make it as bold italic underline or what so if you want to make it as bold just type as bold you see from here the bold is selected if you want to make it as italic you can just search as italic you'll get the italic part and so on if you're not sure what exactly you want to do you can just keep on searching from this area see bold color color index background and if you see size name so on you'll get all the options right now if I want to change the name of the font what I can do is I can just select your name and I can press tab equal to in double quotes you can just type the name right now I want the name as Ariel yeah I'll just write here as Ariel close similarly if I want to make it as bold I'll just type as a 1 to a 10 dot font dot font dot pool equal to true because bold can be either true or false okay because if you see here bold if you can click or you don't click there's only one option whereas in the font you have you click on this drop-down you'll get a list of all the options same way if you want you can write as range a 1 to e 10 dot font dot I want to change the size equal to 20 okay so this way you can keep on writing all this things so this is one method which are given similarly I have written few things at the bottom if I scroll down I'll show you what I have written I have written all this areas let me take time to explain you I'll just bring it on the top I will just press delete from a keyboard like this so it will come on the top yeah okay similarly if you see font dot name I've added two different names if you observe here font name font dot size equal to 20 font bold equal true and false italic true and false okay it went I have to bring that back yeah so again if you see font italic true font or italic false for not underlined so if you observe carefully if you're a non developer if you're finding it very difficult what you can do is see here range a 1 to a 10 is common everywhere font is common everywhere if you see based on that whatever you want if you want bold you see from your desk use bold italic underline similarly you just type as dot name dot underline dot bold dot size dot anything whatever you want you can write and next equal to you'll get all the options obviously you have to keep on practicing till you get perfect with this okay so like this you can keep on writing now if I'll execute that if I want to execute step by step use the shortcut key f8 from a keyboard f8 or else on this debug toolbar you see there's an option given s step into I will press f8 from a keyboard or I can just click on this place okay now if you see that's given as step eight now again if I click on this place a 1 to a 10 I'll get the data here if I place step into that is a 1 to a 10 I've got the data again now it is I want to change the name to s Arial the font name as Arial if I keep my cursor at this place now it is Calibri and if I go back if I press f8 you see now the font change to Arial okay same way I want this to be as bold equal to true so if you see it is not at bold observe here okay if I click on step into now I see it became bold here also it became bold so now I'll use the shortcut key f8 from a keyboard and step by step everything will be executed so you can observe what is happening life f8 font size 20 name change observe here name changed again I'll press f8 size equal to 20 yeah here it is already 20 so no need of changing again bold equal to true false italic true false you see this I am pressing f8 from a keyboard underline true false you see underline again there's one more thing we just left strikethrough if you want to strike through on this place press f8 again you can press f8 to make it false and finally you can press the ends up that is partly done here okay so I hope you able to understand how to play with your font it's very very simple very easy observe the syntax practice it multiple times and you will be able to do it properly right that's all for this video
Info
Channel: Tutorialspoint
Views: 235,846
Rating: undefined out of 5
Keywords: VBA, Marcos, Microsoft, Excel VBA, Excel VBA - Font, Font
Id: Z5knhyubmEk
Channel Id: undefined
Length: 5min 48sec (348 seconds)
Published: Mon Jan 15 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.