ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional statements (https://www.excelbanter.com/excel-programming/302484-conditional-statements.html)

Jon Minken[_2_]

Conditional statements
 
I am a beginner and I am trying to write a conditional
statement that verifys whether or not a cell has a value
greater than zero. If it does, the program contiues to
the output page. If it doesnot, a separate error sheet
pops up that directs the user to return to the sheet and
enter a value. The error sheet appears evey time even if
thecell is greater than zero.

2 Questions.

1. Is their a better way to do this with a message box
that would appear as opposed to referring it to a separate
sheet, and;
2. What is the problem with my program (see below)

Sub Continue_inputs_to_outputs()
'
' Continue_inputs_to_outputs Macro
' Moves the user from the input sheet to the output sheet
provided all the information is complete
'
Sheets("Input Fields Competitve").Select
If Labor_cost 0 Then



Sheets("LPA Competitive Output").Select
ActiveWindow.SmallScroll Down:=-15
Range("G4:R5").Select

Else
Sheets("Warning Page").Visible = True
Sheets("Warning Page").Activate
Range("i20").Select
End If
End Sub

Don Guillett[_4_]

Conditional statements
 
why do you want to select an entire range on your sheet?. What are you going
to do on
Sheets("LPA Competitive Output").Range("G4:R5") ?

Sub Continue_inputs_to_outputs()
' Continue_inputs_to_outputs Macro
' Moves the user from the input sheet to the output sheet
'provided all the information is complete

If Labor_cost 0 Then
application.goto Sheets("LPA Competitive Output").Range("G4:R5")
Else
with Sheets("Warning Page")
.visible=true
applicaton.goto .Range("i20")
end with
End If
End Sub

--
Don Guillett
SalesAid Software

"Jon Minken" wrote in message
...
I am a beginner and I am trying to write a conditional
statement that verifys whether or not a cell has a value
greater than zero. If it does, the program contiues to
the output page. If it doesnot, a separate error sheet
pops up that directs the user to return to the sheet and
enter a value. The error sheet appears evey time even if
thecell is greater than zero.

2 Questions.

1. Is their a better way to do this with a message box
that would appear as opposed to referring it to a separate
sheet, and;
2. What is the problem with my program (see below)

Sub Continue_inputs_to_outputs()
'
' Continue_inputs_to_outputs Macro
' Moves the user from the input sheet to the output sheet
provided all the information is complete
'
Sheets("Input Fields Competitve").Select
If Labor_cost 0 Then



Sheets("LPA Competitive Output").Select
ActiveWindow.SmallScroll Down:=-15
Range("G4:R5").Select

Else
Sheets("Warning Page").Visible = True
Sheets("Warning Page").Activate
Range("i20").Select
End If
End Sub




Jon Minken[_2_]

Conditional statements
 
The intent is2 sheets. The first is an input sheet where
the user inputs their information. At the bottom of the
sheet is a button that they click to take them to the
output sheet. However, I only want them to go to the
output sheet provided they enter a labor value in Cell
named labor cost. If they have not, I want them to be
directed ack to the labor_cost cell to enter.

The range on the output sheet is Just the top cell.

Jon
-----Original Message-----
why do you want to select an entire range on your sheet?.

What are you going
to do on
Sheets("LPA Competitive Output").Range("G4:R5") ?

Sub Continue_inputs_to_outputs()
' Continue_inputs_to_outputs Macro
' Moves the user from the input sheet to the output sheet
'provided all the information is complete

If Labor_cost 0 Then
application.goto Sheets("LPA Competitive Output").Range

("G4:R5")
Else
with Sheets("Warning Page")
.visible=true
applicaton.goto .Range("i20")
end with
End If
End Sub

--
Don Guillett
SalesAid Software

"Jon Minken" wrote in message
...
I am a beginner and I am trying to write a conditional
statement that verifys whether or not a cell has a value
greater than zero. If it does, the program contiues to
the output page. If it doesnot, a separate error sheet
pops up that directs the user to return to the sheet and
enter a value. The error sheet appears evey time even

if
thecell is greater than zero.

2 Questions.

1. Is their a better way to do this with a message box
that would appear as opposed to referring it to a

separate
sheet, and;
2. What is the problem with my program (see below)

Sub Continue_inputs_to_outputs()
'
' Continue_inputs_to_outputs Macro
' Moves the user from the input sheet to the output

sheet
provided all the information is complete
'
Sheets("Input Fields Competitve").Select
If Labor_cost 0 Then



Sheets("LPA Competitive Output").Select
ActiveWindow.SmallScroll Down:=-15
Range("G4:R5").Select

Else
Sheets("Warning Page").Visible = True
Sheets("Warning Page").Activate
Range("i20").Select
End If
End Sub



.


Bob Kilmer

Conditional statements
 
Labor_cost is not defined nor is it assigned a value, at least not in the
code you posted. It will have a value of zero by default. Step through the
code (F8) and see what happens. If you hover your mouse over a variable, its
value will appear in a flyover.

Try substituting True in place of Labor_cost 0 and see if the code
runs as you expect under those conditions.


"Jon Minken" wrote in message
...
I am a beginner and I am trying to write a conditional
statement that verifys whether or not a cell has a value
greater than zero. If it does, the program contiues to
the output page. If it doesnot, a separate error sheet
pops up that directs the user to return to the sheet and
enter a value. The error sheet appears evey time even if
thecell is greater than zero.

2 Questions.

1. Is their a better way to do this with a message box
that would appear as opposed to referring it to a separate
sheet, and;
2. What is the problem with my program (see below)

Sub Continue_inputs_to_outputs()
'
' Continue_inputs_to_outputs Macro
' Moves the user from the input sheet to the output sheet
provided all the information is complete
'
Sheets("Input Fields Competitve").Select
If Labor_cost 0 Then



Sheets("LPA Competitive Output").Select
ActiveWindow.SmallScroll Down:=-15
Range("G4:R5").Select

Else
Sheets("Warning Page").Visible = True
Sheets("Warning Page").Activate
Range("i20").Select
End If
End Sub




Bob Kilmer

Conditional statements
 
If Labor_cost is a named range, use:

If Range("Labor_cost").Value < 0 Then
''whatever
Else
MsgBox "Labor cost is incorrect" 'or other message
Application.Goto Range("Labor_cost")
End If

"Jon Minken" wrote in message
...
I am a beginner and I am trying to write a conditional
statement that verifys whether or not a cell has a value
greater than zero. If it does, the program contiues to
the output page. If it doesnot, a separate error sheet
pops up that directs the user to return to the sheet and
enter a value. The error sheet appears evey time even if
thecell is greater than zero.

2 Questions.

1. Is their a better way to do this with a message box
that would appear as opposed to referring it to a separate
sheet, and;
2. What is the problem with my program (see below)

Sub Continue_inputs_to_outputs()
'
' Continue_inputs_to_outputs Macro
' Moves the user from the input sheet to the output sheet
provided all the information is complete
'
Sheets("Input Fields Competitve").Select
If Labor_cost 0 Then



Sheets("LPA Competitive Output").Select
ActiveWindow.SmallScroll Down:=-15
Range("G4:R5").Select

Else
Sheets("Warning Page").Visible = True
Sheets("Warning Page").Activate
Range("i20").Select
End If
End Sub





All times are GMT +1. The time now is 06:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com