Now your variable will have the value.įor simplicity sake of learning, you can remove or comment out the Option Explicit line and VBA will try to determine the type of variables at run time. This assumes you have a number (like 5) in cell D6. MyVariableName = ActiveSheet.Range("D6").Value Mickey Lawson is considering investing some money that he inherited. Try something like this: Dim MyVariableName As Integer Decision Analysis Using Excel QM In this tutorial, we will work through a problem using decision analysis in Excel QM. I'm assuming you want the value stored in a variable. This could be a integer or a string for example (depends on what you have in that cell) but it's not a range. This line: Set envFrmwrkPath = ActiveSheet.Range("D6").Value is attempting to set the Range type variable to a specific Value that is in cell D6. This means that you can only set it to a range. This line: Dim envFrmwrkPath As Range is declaring the variable envFrmwrkPath of type Range. They can be any type, including object, integer, string, or even a variant. The first code line, Option Explicit means (in simple terms) that all of your variables have to be explicitly declared by Dim statements.
0 Comments
Leave a Reply. |