Greetings, I have learned a lot from all of you but I still struggle with multiple "if/then's"... Below is a snippet of code from a userform that I use to enter chemical usage data into a spreadsheet. The form works fine, but now I need to make a tweak to it. I currently have it set to take the value that is on the last filled cell in column "E", divide it by 51 plus multiply it by 24, and then place it in the next blank cell in column "F". This tells me how many gallons an hour I am using.
But now I need to use this form to account for barrels that have different amounts in them, instead of them all being the same 51 gallons. Some have 47, some have 60.75. We can call them chemicals "A", "B" or "C".
In the syntax for "chemicalbox.value" I have it set to see the name of the chemical, so my thinking that in .Range "F" I need to put an if/then statement so that if it sees one chemical then it will use the specific value for the division. I keep getting the formatting wrong and I am sure that it is with my structuring, could someone give me an idea on how you would structure the if/then statements?
Thank you for any assistance.
But now I need to use this form to account for barrels that have different amounts in them, instead of them all being the same 51 gallons. Some have 47, some have 60.75. We can call them chemicals "A", "B" or "C".
In the syntax for "chemicalbox.value" I have it set to see the name of the chemical, so my thinking that in .Range "F" I need to put an if/then statement so that if it sees one chemical then it will use the specific value for the division. I keep getting the formatting wrong and I am sure that it is with my structuring, could someone give me an idea on how you would structure the if/then statements?
Thank you for any assistance.
VBA Code:
'transfer the data
With ActiveSheet
nextrow = .Range("A" & Rows.Count).End(xlUp).Row + 1
lastrow = .Range("D" & Rows.Count).End(xlUp).Row - 0
.Range("A" & nextrow) = ChemicalBox.Value
.Range("B" & nextrow) = LotNumber.Value
.Range("C" & nextrow) = TechName.Value
.Range("D" & nextrow) = Now() - (TimeLog.Value * oneMin) 'this tells me when the barrel changed over
.Range("G" & nextrow) = CommentBox.Value
.Range("E" & nextrow) = Now() - (TimeLog.Value * oneMin) - .Range("D" & lastrow) 'this tells me how long the barrel was online
.Range("F" & nextrow) = 51 / (.Range("E" & nextrow) * 24) 'this tells me how many galllons per hour were used.
End With