ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can we use variables in XL macros? (https://www.excelbanter.com/excel-programming/429269-can-we-use-variables-xl-macros.html)

Patrick Molloy

Can we use variables in XL macros?
 
su

DIM sPath as String
sPath = "c:\windows\temp"
Shell sPath

"StargateFan" wrote in message
...
I have little experience scripting generally, but have a lot with
AutoIt, a freeware scripting language. One of the very cool features
is the way we can use variables to make life a whole lot easier, for
example.

;=======================
$Path = "c:\windows\temp"
;=======================

Shellexecute($Path)


The advantage of the above is that it's easy to make a script that you
just plug in the changing values at the top and then not touch the
content. This is a very simpe example, but sometimes things can get
pretty complicated and using variables in this manner really
simplifies things.

Is there a comparable system in Excel so that we can put all variables
at the top and leave the rest of the script to do the tasks?

Thanks! :oD


Peter T

Can we use variables in XL macros?
 
At the top of the module

Private Const cPATH As String = "c:\windows\temp"
Public Const cNUM as Long = 123

The private constant will be visible to all procedures in the module, the
public one throughout the project.

Regards,
Peter T


"StargateFan" wrote in message
...
I have little experience scripting generally, but have a lot with
AutoIt, a freeware scripting language. One of the very cool features
is the way we can use variables to make life a whole lot easier, for
example.

;=======================
$Path = "c:\windows\temp"
;=======================

Shellexecute($Path)


The advantage of the above is that it's easy to make a script that you
just plug in the changing values at the top and then not touch the
content. This is a very simpe example, but sometimes things can get
pretty complicated and using variables in this manner really
simplifies things.

Is there a comparable system in Excel so that we can put all variables
at the top and leave the rest of the script to do the tasks?

Thanks! :oD




StargateFan

Can we use variables in XL macros?
 
I have little experience scripting generally, but have a lot with
AutoIt, a freeware scripting language. One of the very cool features
is the way we can use variables to make life a whole lot easier, for
example.

;=======================
$Path = "c:\windows\temp"
;=======================

Shellexecute($Path)


The advantage of the above is that it's easy to make a script that you
just plug in the changing values at the top and then not touch the
content. This is a very simpe example, but sometimes things can get
pretty complicated and using variables in this manner really
simplifies things.

Is there a comparable system in Excel so that we can put all variables
at the top and leave the rest of the script to do the tasks?

Thanks! :oD



All times are GMT +1. The time now is 02:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com