#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 460
Default <1000

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default <1000

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
--
HTH,

Barb Reinhardt



"Doug" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 460
Default <1000

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

"Barb Reinhardt" wrote:

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
--
HTH,

Barb Reinhardt



"Doug" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
devide by 1000 Atiq Excel Discussion (Misc queries) 5 April 29th 09 08:52 PM
1000-200*4% add deepak Excel Discussion (Misc queries) 2 June 26th 07 08:31 AM
1000 to 1 and 1 to 1000 Olle Excel Worksheet Functions 5 October 6th 06 02:41 PM
For i = 5 to 1000 for columns? [email protected] Excel Programming 4 July 31st 06 11:49 AM
1000+$K$5/1000 -what does $ indicate in formula Coolbhims Excel Worksheet Functions 1 March 16th 06 11:51 AM


All times are GMT +1. The time now is 04:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"