Names can also be used to store numbers between sessions. Use NumofSales = 5123

Names.Add Name:="TotalSales", RefersTo:=NumofSales Or

Names.Add Name:="TotalSales", RefersTo:=5123

Notice the lack of quotes or an equal sign. Using quotes changes the number to a string; and with the addition of an equal sign, the number changes to a formula.

To retrieve the value in the name, there are two options: NumofSales = Names("TotalSales").Value

Or the shorter version: NumofSales = [TotalSales]

Keep in mind that someone reading your code may not be familiar with the use of the Evaluate method (square brackets). If you know that someone else will be reading your code, avoid the use of the Evaluate method or add a comment explaining it.

0 0

Post a comment