PC Review


Reply
Thread Tools Rate Thread

changing constants

 
 
electricbluelady
Guest
Posts: n/a
 
      24th Jun 2008
HI Everyone,
When billing every month there are 'constants' that change. Currently, I am
trying to design a way where a user does not have to go into the program
every month to change 'constants'. Is there a way to refer to a cell as a
'constant'? This is what I have so far....

Const D37 as Long = 10000.
Next month D37 may be 11000. The number is entered into the spreadsheet, but
the macro runs formulas off of the declared constant in the macro.

Thanks again.
--
Thank you,
Electricbluelady
 
Reply With Quote
 
 
 
 
RyanH
Guest
Posts: n/a
 
      24th Jun 2008
I would do this. I'm not sure how many constants you have, so I did six.
Replace "Sheet1" with the Worksheet Name the constants are located in and
change the "A1" with the cell the constant is located in.

Then replace your old numbers in the macros with the constant variables I
listed below.

Sub Macro1()

Dim constant1 As Range
Dim constant2 As Range
Dim constant3 As Range
Dim constant4 As Range
Dim constant5 As Range
Dim constant6 As Range

constant1 = Sheets("Sheet1").Range("A1").Value
constant2 = Sheets("Sheet1").Range("A2").Value
constant3 = Sheets("Sheet1").Range("A3").Value
constant4 = Sheets("Sheet1").Range("A4").Value
constant5 = Sheets("Sheet1").Range("A5").Value
constant6 = Sheets("Sheet1").Range("A6").Value

'the rest of your code here

End Sub

"electricbluelady" wrote:

> HI Everyone,
> When billing every month there are 'constants' that change. Currently, I am
> trying to design a way where a user does not have to go into the program
> every month to change 'constants'. Is there a way to refer to a cell as a
> 'constant'? This is what I have so far....
>
> Const D37 as Long = 10000.
> Next month D37 may be 11000. The number is entered into the spreadsheet, but
> the macro runs formulas off of the declared constant in the macro.
>
> Thanks again.
> --
> Thank you,
> Electricbluelady

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      24th Jun 2008
Let's say the value for D37 is already being entered in Sheet1, cell D37. In
VBA:

Sub dural()
Dim D37 As Long
D37 = Sheets("Sheet1").Range("D37").Value
End Sub

--
Gary''s Student - gsnu200793


"electricbluelady" wrote:

> HI Everyone,
> When billing every month there are 'constants' that change. Currently, I am
> trying to design a way where a user does not have to go into the program
> every month to change 'constants'. Is there a way to refer to a cell as a
> 'constant'? This is what I have so far....
>
> Const D37 as Long = 10000.
> Next month D37 may be 11000. The number is entered into the spreadsheet, but
> the macro runs formulas off of the declared constant in the macro.
>
> Thanks again.
> --
> Thank you,
> Electricbluelady

 
Reply With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      24th Jun 2008
Your question is how to change constants. But if they are changing then they
are not constants. Constants are used for holding values that you never
expect to change. Pi is a contant. The number of hours in a day is a contant.
If you reasonably expect the value to change then store it in a user
accessable location in your spreadsheet and then read that value at run time,
similar to Ryan and Gary's suggestions.
--
HTH...

Jim Thomlinson


"electricbluelady" wrote:

> HI Everyone,
> When billing every month there are 'constants' that change. Currently, I am
> trying to design a way where a user does not have to go into the program
> every month to change 'constants'. Is there a way to refer to a cell as a
> 'constant'? This is what I have so far....
>
> Const D37 as Long = 10000.
> Next month D37 may be 11000. The number is entered into the spreadsheet, but
> the macro runs formulas off of the declared constant in the macro.
>
> Thanks again.
> --
> Thank you,
> Electricbluelady

 
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
Changing constants in a query to user input values PamB Microsoft Access Queries 2 4th Jun 2010 05:52 AM
constants =?Utf-8?B?Q29uZnVzZWQ=?= Microsoft Excel Misc 3 2nd Dec 2004 05:05 PM
changing the constants in the find function =?Utf-8?B?T2tpZVZpa2luZw==?= Microsoft Excel Programming 2 1st Jul 2004 05:38 PM
integer constants used with string constants Eric Newton Microsoft Dot NET Framework 3 14th Jan 2004 05:05 AM
ADO Constants Wayne Wengert Microsoft ADO .NET 1 24th Jul 2003 02:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:19 PM.