View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default User-changeable paths into Excel - avoid hard coding

Did that line work for you?

It didn't for me.

DaveO wrote:

True, but a constant can be defined as a range value. It's the holder's
contents that have to remain static, not the value itself.

For the purposes of the routines running, the data should remain the same.

I've never tried doing it, but it works in other code I've written from
other apps. Othwise, just declare a Public variable and set it on initialise.

"Dave Peterson" wrote:

But constants have to be constants.

DaveO wrote:

My suggestion would be to create publis constants.

Eg...

--------------------------------------------------------

Option Explicit

Public Const cstMyPath as String = Range("MY_Path").Value

---------------------------------------------------------

This would be how I'd do it, or else create a message box for them to enter
it in. Either way works.

HTH.

"gearoi" wrote:


Hello all,

I want to enable my non-VBA friendly users to be able to change the
paths that various files are pulled from / saved to via Excel.

At the moment the paths are hard coded - they are of the non-geeky
variety (unlike me ;) ) and do NOT want to go into the VBA to change
them.

So I have made a table in Excel for them to enter the paths.

My project has many, many modules and subroutines. I can't declare and
set the variables to the path names once, as I'd have to do it in each
sub/module.

SO my question is - is there a way of making global constants which are
set up from stuff in the excel sheet (e.g. range("mypath").value )?

Or maybe there is a better way...?

Thanks for your help.

Brgds,
Graham


--
gearoi
------------------------------------------------------------------------
gearoi's Profile: http://www.excelforum.com/member.php...o&userid=26576
View this thread: http://www.excelforum.com/showthread...hreadid=400711



--

Dave Peterson


--

Dave Peterson