I want to declare a variable in vba code of an Excel document and use it in a cell.
Something like this:
Vba Code:
Dim foo as Integer
foo = 2
Excel Cell (any)
=foo
Is that possible?
You can declare public function in a code module
Public Function Foo() As Integer
Foo = 2
End Function
and use it in a cell
=Foo()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.