PC Review


Reply
Thread Tools Rate Thread

how do I link a constant or variable to form

 
 
c1802362
Guest
Posts: n/a
 
      13th Sep 2011
I created a spreadsheet that retrieves a large data set and based on
options the user selects, the data is reduced and plotted accordingly.
Currently, the source data file name and location is hardcoded as a
constant into the spreadsheet file to eliminate the complex method
required to retrieve the source data (our IT department's doing) .
Unfortunately, every few months the source data file name gets
changed, (another IT issue) which is OK, as I can replace the constant
info in a few seconds.

What I'd like to do is enable the userform to display the source data
file name at the bottom of the form to alert the user which data set
they're using.

How do I retrieve a constant from VB code and add it as a label to a
form?

Art
 
Reply With Quote
 
 
 
 
GS
Guest
Posts: n/a
 
      13th Sep 2011
It happens that c1802362 formulated :
> I created a spreadsheet that retrieves a large data set and based on
> options the user selects, the data is reduced and plotted accordingly.
> Currently, the source data file name and location is hardcoded as a
> constant into the spreadsheet file to eliminate the complex method
> required to retrieve the source data (our IT department's doing) .
> Unfortunately, every few months the source data file name gets
> changed, (another IT issue) which is OK, as I can replace the constant
> info in a few seconds.
>
> What I'd like to do is enable the userform to display the source data
> file name at the bottom of the form to alert the user which data set
> they're using.
>
> How do I retrieve a constant from VB code and add it as a label to a
> form?
>
> Art


Assign the 'Text' of the cell containing the filename info to the
'Caption' property of the label on your userform in the form's
Initialize event.

Example: (air code)
lblDataSource.Caption = Range("DataSource").Text

..where 'lblDataSource' is the name you give to the target label, AND
"DataSource" is the local scope name you give to the cell where the
filename resides.

To give a named range local scope:
Select the range
In the namebox to left of the Formula Bar, type:

'<sheet name>'!DataSource

..where <sheet name> should be replaced with the actual worksheet
name

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
Reply With Quote
 
GS
Guest
Posts: n/a
 
      13th Sep 2011
GS explained :
> To give a named range local scope:
> Select the range
> In the namebox to left of the Formula Bar, type:
>
> '<sheet name>'!DataSource
>
> ..where <sheet name> should be replaced with the actual worksheet name


Be sure to press 'Enter' after typing in the namebox!

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
Reply With Quote
 
c1802362
Guest
Posts: n/a
 
      13th Sep 2011
Thanks - it works, although I was hoping to avoid the intermediate
step of writing the filename to a cell before transferring it to the
form. Right now the file name is a string constant at the head of the
VBA code, but I have a hidden sheet full of info I used per your
directions

By the way, I had to modify your syntax to:
form1.lblDataSource.Caption = Range("DataSource").Text
to get an object reference

Art


On Sep 13, 1:06*pm, GS <g...@somewhere.net> wrote:
>
> Assign the 'Text' of the cell containing the filename info to the
> 'Caption' property of the label on your userform in the form's
> Initialize event.
>
> * Example: (air code)
> * * lblDataSource.Caption = Range("DataSource").Text
>
> * ..where 'lblDataSource' is the name you give to the target label, AND
> "DataSource" is the local scope name you give to the cell where the
> filename resides.
>
> * To give a named range local scope:
> * * Select the range
> * * In the namebox to left of the Formula Bar, type:
>
> * * * '<sheet name>'!DataSource
>
> * * ..where <sheet name> should be replaced with the actual worksheet
> name
>
> --
> Garry
>
> Free usenet access athttp://www.eternal-september.org
> ClassicVB Users Regroup! comp.lang.basic.visual.misc- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I get "CONSTANT" behavior from a variable (Constant magic)? bobg.hahc@gmail.com Microsoft Access Form Coding 19 7th Feb 2008 04:38 AM
How can I get "CONSTANT" behavior from a variable (Constant magic)? bobg.hahc@gmail.com Microsoft Access VBA Modules 3 5th Feb 2008 08:04 PM
Variable link to a text box on a form billybanter67 Microsoft Access Reports 4 4th Oct 2007 12:23 PM
constant variable =?Utf-8?B?dGlt?= Microsoft Access 14 6th Apr 2006 02:00 PM
Is it possible to open the VBA form with a link in a sheet and to pass variable from a cell to the VBA form? Daniel Microsoft Excel Programming 1 29th Aug 2004 01:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:30 AM.