I currently have a spreadsheet that has a nested IF statement to determine some quantities, and I think it may be better to use the Select Case instead of what I have, but I'm a little unsure as how to go about that. Here's my current forumla:
=IF(F2="lbs",SUM(B2*E2)/0.7,IF(F2="ea",SUM(B2*E2),IF(F2="sqft",SUM(B2*E2)/0.7,IF((AND(F2="in",H2="ft")),ROUNDUP(SUM(B2*E2)/12,0),ROUNDUP(SUM(B2*E2,1),ROUNDUP(E2,0))))))
As of now, I have an unknown number of items that will be on this worksheet. The number will vary each time someone does a new export of this data to the spreadsheet. It could be 7 items, could be 25, could be 100. What I need to be able to do is find the value in column F on my spreadsheet, and then perform the calculations as shown in the formula above based off of what that value is (it will either be lbs, ea, in, sqft, or ft). To throw another wrinkle into it, the one calculation takes into account both column F and column H, in order to do a translation from inches to ft. So, can I use Select Case with a range of the entire column F to do this, as I do not know how many items will be in the spreadsheet. I can get the basics of the Select Case, but I'm unsure of the best way to go about it for the entire range. For example, if I was doing just row two in my spreadsheet I would take it as:
Select Case Range("F2")
Case lbs
Range("G2") = ("B2" * "E2") / 0.7
Case ea
Range("G2") = ("B2 * "E2")
Case sqft
Range("G2") = ("B2" * "E2") / 0.7
Case Else
Range("G2") = " "
End Select
The other thing I'm unsure of in the Select Case statement would the how to go about finding when column F is inches (in) and column H is feet (ft). Do I need a separate statement for that? Thanks for any help.
=IF(F2="lbs",SUM(B2*E2)/0.7,IF(F2="ea",SUM(B2*E2),IF(F2="sqft",SUM(B2*E2)/0.7,IF((AND(F2="in",H2="ft")),ROUNDUP(SUM(B2*E2)/12,0),ROUNDUP(SUM(B2*E2,1),ROUNDUP(E2,0))))))
As of now, I have an unknown number of items that will be on this worksheet. The number will vary each time someone does a new export of this data to the spreadsheet. It could be 7 items, could be 25, could be 100. What I need to be able to do is find the value in column F on my spreadsheet, and then perform the calculations as shown in the formula above based off of what that value is (it will either be lbs, ea, in, sqft, or ft). To throw another wrinkle into it, the one calculation takes into account both column F and column H, in order to do a translation from inches to ft. So, can I use Select Case with a range of the entire column F to do this, as I do not know how many items will be in the spreadsheet. I can get the basics of the Select Case, but I'm unsure of the best way to go about it for the entire range. For example, if I was doing just row two in my spreadsheet I would take it as:
Select Case Range("F2")
Case lbs
Range("G2") = ("B2" * "E2") / 0.7
Case ea
Range("G2") = ("B2 * "E2")
Case sqft
Range("G2") = ("B2" * "E2") / 0.7
Case Else
Range("G2") = " "
End Select
The other thing I'm unsure of in the Select Case statement would the how to go about finding when column F is inches (in) and column H is feet (ft). Do I need a separate statement for that? Thanks for any help.