Excel VBA - Font Color

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we'll see how to change the color of your font into your excel will be writing this in the form of a macro in the VBA editor so let us see that what I've done is I've written some text into this place the same text utils point okay in the sheet named s H underscore font underscore color Excel VBA file itself now if I want to change the font color I usually do it with the help of this font group okay I can change the font color from here but the temp of macros how do I do that let us see that I'll open the VBA editor part so this is my VBA editor part I've created here a sheet here a model that is H underscore font underscore colors in the module folder itself now I have created inside that module sub procedure that is font underscore color so if you want to can change the name here if you want you can change the name here just for your understanding I have given some meaningful name okay so let us see that if you want to change the color of your font okay that is this area how do you change it first thing is you have to write the area name that is the cell name which you want to change so I'll type here as range a12 8m though there are many cells it is from a1 to a 17 I don't want to change entirely I want a 1 to a 10 and then I can write as font because in that range I have some fun and I want to change the color okay so that is all rest is I have to type the name of the color so equal to vb v b stands for visual basic and you just type here as green okay same way you can keep on writing instead of this green you can keep on writing different names which is it can be green basically there are only eight colors eight standard colors i will try to say that black white red green yellow blue cyan and magnetar so basically there are eight colors okay into this these are standard colors there are more than eight colors but for that you don't have this names so names are given for each standard colors so let us see that so it's only thing which you have right range a 1 to a 10 dot font color equal to VB green similarly I have written eight more sentences here statements I'll show you those statements I have written at the bottom I'm bringing it up now if you see so similarly I have just copy/paste here like this one okay and instead of green have written this eight colors okay black white green yellow blue red then you have San and Magneto these are the new two colors which I added here there's one more method which you can use to add the colors if you want to change the font color there's one more method instead of this color you just type eros color index so how do you write it I just try to show you here range that is a 1 to a 10 dot font dot color index equal to 1 okay so like this what I have written is dot color index instead of this color I have written the color index index it starts with the number you can start from one number 256 5 6 number 56 if you try to write 57 it will not be valid okay so it only works in this two areas if you want to change the font color either type font or color or font color index similarly for this area I have written some text at the back end in the lower place I'll just bring it up if you see yeah I brought it up so this is what I've written font color index 110 and fifty till 56 it will work apart from 56 that you show it will try an error message so what I'll do is I'll bring this up I'll delete this space which I've given here yeah yeah this is what I've done right so for your reference whatever written is there are only 8 standard colors for this one there are color index till 56 if you write 57 it will throw an error message let us execute and see what happens now if you want to execute step by step you have to use the shortcut key as f8 from a keyboard that is nothing but step into yeah let us see now if I click on this step into you see the first line now it it will go to the next place now it says VB green observe here the color when it goes to the next line that means a local ament's it is executing that line now f8 now yeah a 1 to a 10 is only clean why only a 1 to a 10 because I have selected a 1 to a 10 now keep on observing if I press f8 from a keyboard now it is white color white color will match with the background white color so it will be shown nothing f8 now it is black color again f8 I have written as L nope red green blue cyan magnetar and so on so it is changing the colors again if you see I have written the color index as 1 so this the color index for one which is a black so it will keep on changing if the color index changes the number that is given as 10 again it is given as 10 and 50 so it went back I have to go back to this place yeah and finally if I press f8 this is for 50 so 50 stands for somewhere light green color again I'll press f8 so it came back way so I hope you have understood how to change the colors of the font there are two methods basically for font color and font color index that's it that's all for this video
Info
Channel: Tutorialspoint
Views: 147,096
Rating: undefined out of 5
Keywords: VBA, Marcos, Microsoft, Excel VBA, Excel VBA - Font Color, Font Color
Id: S9nH8CFD4RA
Channel Id: undefined
Length: 4min 55sec (295 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.