<1000

D

Doug

The program below looks at a cell to see if the cell is >=5000 and if it is
adds a cost to another set of cells on the sheet. All works well until I have
an entry less than 1000. At this point it adds the cost anyway when it should
not. I need to know how to make this work when below 1000.

Thanks,
Doug

If ChkGenset.Value = False Then
Sheets("Tank").Unprotect Password:="benjamin"
Sheets("TankCalcs").Unprotect Password:="benjamin"
Sheets("TankCalcs").Range("I22").Value = ""
Sheets("Tank").Range("C13").Value = ""
Sheets("Tank").Range("F56").Value = ""
Sheets("Tank").Range("G56").Value = ""
ChkWP.Enabled = True
ChkSA.Enabled = True
Sheets("Tank").Protect Password:="benjamin"
Sheets("TankCalcs").Protect Password:="benjamin"

Else: Sheets("Tank").Unprotect Password:="benjamin"
Sheets("TankCalcs").Unprotect Password:="benjamin"
Sheets("TankCalcs").Range("I22").Value = "3"
Sheets("Tank").Range("C13").Value = Sheets("TankCalcs").Range("J30")
ChkWP.Enabled = False
ChkSA.Enabled = False
Sheets("Tank").Range("F56").Value = ""
Sheets("Tank").Range("G56").Value = ""
'looks at Total Gal of tank and if equal to or greater than 5000gal
it automatically adds the cost and weight of a manhole
If Sheets("Tank").Range("C7").Value >= "5000" Then
Sheets("Tank").Range("F56").Value =
Sheets("TankCalcs").Range("H2").Value
Sheets("Tank").Range("G56").Value =
Sheets("TankCalcs").Range("I2").Value
End If
Sheets("Tank").Protect Password:="benjamin"
Sheets("TankCalcs").Protect Password:="benjamin"
End If
 
B

Barb Reinhardt

Try this with a few tweaks.

Option Explicit
Sub Test()
Dim myTank As Worksheet
Dim myTankCalcs As Worksheet

Set myTank = Worksheets("Tank")
Set myTankCalc = Worksheets("TankCalcs")

If ChkGenset.Value = False Then
myTank.Unprotect Password:="benjamin"
myTankCalcs.Unprotect Password:="benjamin"
myTankCalcs.Range("I22").Value = ""
myTank.Range("C13").Value = ""
myTank.Range("F56").Value = ""
myTank.Range("G56").Value = ""
ChkWP.Enabled = True
ChkSA.Enabled = True
myTank.Protect Password:="benjamin"
myTankCalcs.Protect Password:="benjamin"

Else:
myTank.Unprotect Password:="benjamin"
myTankCalcs.Unprotect Password:="benjamin"
myTankCalcs.Range("I22").Value = "3"
myTank.Range("C13").Value = myTankCalcs.Range("J30")
ChkWP.Enabled = False
ChkSA.Enabled = False
myTank.Range("F56").Value = ""
myTank.Range("G56").Value = ""
'looks at Total Gal of tank and if equal to or greater than 5000gal
'it automatically adds the cost and weight of a manhole
If myTank.Range("C7").Value >= 5000 Then 'Changed from "5000"
myTank.Range("F56").Value = myTankCalcs.Range("H2").Value
myTank.Range("G56").Value = myTankCalcs.Range("I2").Value
End If
myTank.Protect Password:="benjamin"
myTankCalcs.Protect Password:="benjamin"
End If
End Sub
 
D

Doug

Barb,
Thanks for your suggestion. I reviewed the changes you made and saw that you
removed the quotation marks from the 5000 and tried that first rather than
making all the other changes, it worked. I guess I thought since it was a
number referenced in a cell it had to have the quotation marks.

Thanks,
Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top