filmov
tv
Add Current Date and Time using a Macro | Excel VBA
Показать описание
📰 Transcript
Hey, this is Puneet back again. And welcome to our VBA series where we learn to write codes in Excel. And before we jump in, make sure to subscribe to the channel so that you won't miss any of these videos in coming weeks. And now let's get started. In VBA, there is a function called date that we can use to insert or get the current date as per the system. So here I'm going to insert the current date in the cell A1. So first of all I'm going to specify the cell A1 and then I'm going to assign the value that coming from function date. So when you're using this date function, you don't need to specify any argument, you simply need to use the word, the keyword Date. That's it. So now when I run this code it gives me the current date as per my system and it inserts it into the cell A1. And in the same way, if you want to get the current date and current time, you can use this function called NOW. And this function also doesn't need any argument to be specified by you. You simply need to use the keyword NOW. And now, if I run this code, it gives me the current date and the current time into the cell a one. Now let's suppose you need that date or time in a specific format, a custom format. In that case you can use this function called Format and then define Date function to get the date. And in the second argument you can define the format of the date. So I'm going to use DD. And now if I run this code it gives me the date into the format that I have specified. All right, so that's it for this video. I hope you found this quick VBA tip useful. And if you want to learn more, make sure to subscribe to this channel because I'll be coming out of a lot of cool VBA tips and tricks in coming weeks.
---------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
#ExcelVBA #LearnVBA #VBATutorial #VBA
Комментарии