variable variable based on other variables?!

witham

New Member
Joined
Nov 9, 2011
Messages
31
Hi All,

If I wanted to state a variables value based on another variable, how could I do that?

The two variables I current have in the script are

Code:
Dim Red as Long
Dim Green as Long
Dim Amber as Long

Green = Sheets("HURDLES").Range("C5").Value
Red = Sheets("HURDLES").Range("E5").Value

What I want to achieve is establish Amber as being between Green +1 & Red -1

Any help appreciated!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hmm, not sure that will do it AlphaFrog, it is a definite range between the red and green, not an average of them.
 
Upvote 0
A Long can only be one value, not a range. What exactly are you trying to do?
 
Upvote 0
it is a definite range between the red and green
I don't understand what that means.

Amber = Abs(Green-Red)

This will calculate the absolute difference. That is sort of a range. Is that what you want?
 
Last edited:
Upvote 0
Hi Guys,

I think I sorted it a different way. I can see how it cannot be a range so I sorted it with an IF, IF greater than Red & less than Green.
That seems to have sorted it.

Thank you for your help!
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,685
Members
448,977
Latest member
dbonilla0331

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top