Hey guys, welcome back. So in this video we're going to discuss the dot formula property for the range object. So what the dot formula property does is that it outputs the formula of the range object that you use it on. However, it can only work with objects having single cells, okay? So with range objects only having single cells, so you could use it with range a one for example, but it cannot work with range objects that are having multiple cells, right? Because you cannot output the formula of multiple cells at the same time.
So you can't use it on range a one to D five, for example. Okay, so the range object that you would use it with, needs to have only just a single cell. Okay, so to have an example here, I've got a Sub procedure that is called range underscore for me that that I've created. And remember guys, we've got a named range called my underscore table that We have created before, okay, so if I write on cell D 14 equals some, my underscore table, and I've actually popped the value of 10 in each cell of the range called Molly underscore table, and this range consists of 60 cells, so the summation should be 600. Okay? And if we go back to the Visual Basic environment, and we would write range, d 14 dot formula, okay, and we put that inside a message box, and we run that we will actually get a message box containing the exact formula that we've written in cell D 14.
So if you run that, you can see here we got the formula in cell D 14. However, if I do range d 14 dot value, I would get actually the value that is in cell D four tene, which is 600. Okay, so you're able to retrieve the format of a cell, or from a cell using the range dot format up property. However, you're also able to write the formula in a cell. So you can write a certain formula in Excel using the range dot formula property. So let's say I'm going to write this same formula here, but using VBA.
So I'm going to delete it from cell D 14. And then I'm going to write range d 14 dot formula equals, and then I actually need to write the exact formula, but between double quotes, so equals sum of my underscore table between double quotes. So if I run that, this is going to write the formula and we're going to get the result which is 600. The same result, you could also use the dot value property as well and that is going to write the formula correctly as well. So if I delete that Go back and use the value property, this as well we write the formula correctly, and everything's just going to be fine. And this formula, of course works and it updates if I just change the value of one of the cells.
You can see here that the formula updates. I'm just going to press Ctrl and z here. Okay, so that's it, guys for the dot formula property. Thank you very much for watching this video and I'll see you on the next one.