Bob,
I don't know was you mean by "...move a cell around..."
If I use my mouse on the spreadsheet to move cell $N$7 which has a name of "NetWeight" to cell $N$24, the name manager automatically compensates for the change (Netweight=$N$7, =$N$24)Q1: If I use the cells "Name" in the VBA code (rather than $N$7, then I don't think I have to worry about updating the VBA if I move the cell from N7 to N24...Right?
Q2: Or...maybe because I didn't use the "$" sign in the VBA, I had to update the code when i move N7 to N24?
Let's assume for a minute that cell N6 (NetWeigh) has a value of 11066
This value was established by a "TextBox" on a userform with a name of "NetWeight" (value converted to an integer)
Cell N7 is named "CylQty", and has a value of "2" (total quantity of cylinders, each with the same netweight).
The value was established by a "TextBox" on the same userform with a name of "CylQty"
Cell N8 is named "TotNtWt" (Total Net Weight) and needs to hold the total net weight.
A variable would be associated with N8 of "TotNtWt" for consistence and possible use elsewhere in the code.
Q3: Is using the same name in the "Name Manager" as in a VBA Variable good, or poor code practice?
I like TMS's idea...
I normally prefix named ranges with "nr" and variables with their type
On paper the equation would look like NetWeight x CylQty = TotNtWt.
This math is about 1/10th as complex as most of the equations so most of the formulas would be much longer and harder to decipher.
Q4: Would using variables to perform calculations in the VBA yield shorter equations that might be simpler to follow?
Q5: Would using variables allow for faster, or slower execution, or would it matter?
Bookmarks