Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having difficulty with ElseIf statement

Status
Not open for further replies.

Randy11

Technical User
Oct 4, 2002
175
CA
Have code set up below with several cases that works excellent when a cell in a workbook changes to value identified it runs the if , then code. Problem is if a record is reversed need the value in cell J4 to revert to True vs false which is trigger by then statement prior. IfElse statement is intended to do this but fails. < is causing the issue, not sure how to complete the statement. Essentually if I2 = Value do this, if less than Value do that.
Assistance appreciated. Arg!

Sub KillList()

Dim cellValue As Integer

cellValue = Sheets("Endlist").Range("I2").Value

Select Case cellValue

Case Sheets("Endlist").Range("I4").Value
If Sheets("Endlist").Range("J4").Value Then
MsgBox ("Print 1st Endlist, Repair Endlist count " & cellValue + 1)
Sheets("Endlist").Range("J4").Value = "False"
Call CutRepairEndlist
Call PrintKillListOne
ElseIf Sheets("Endlist").Range("I4").[<]Value Then
Sheets("Endlist").Range("J4") = "True"

End If
 

So you are looking at [tt]Sheets("Endlist").Range("I4").Value
[/tt] - what IS the value in this cell?

Your IF statement here:
[tt]
If Sheets("Endlist").Range("J4").Value Then
[/tt]
will return True for any value other than 0 (zero)

I think you need something like:
[tt]
If Sheets("Endlist").Range("J4").Value [red]= ???[/red] Then[/tt]


Have fun.

---- Andy
 
I2 is the cell that contains the changing value

Cells
I4, I5, I6 etc contain the match values for the cases.
K4, K5, K6 have either False or True in them

i.e.
1st Case if I2 = I4 Then
Code makes cell J4 = False & then some other functions
elseif I2 does not = J4 then
Code make J4 = True ( this is what I am looking for)

So if an operator revereses an entry & value in I2 drops below threashold in I4, J4 changes back to True
Sorry if I was not clear.
Thanks again.
 

IfElse statement is intended to do this but fails. < is causing the issue, not sure how to complete the statement.
Code:
Case Sheets("Endlist").Range("I4").Value
  If Sheets("Endlist").Range("J4").Value [red]= what?[/red] Then
    MsgBox ("Print 1st Endlist, Repair Endlist count " & cellValue + 1)
    Sheets("Endlist").Range("J4").Value = "False"
    Call CutRepairEndlist
    Call PrintKillListOne
  ElseIf Sheets("Endlist").Range("I4").Value [red]< what?[/red] Then
    Sheets("Endlist").Range("J4") = "True"
  [blue]Else
    ....[/blue][green]'What happens here?[/green]
  End If
Case ....
If you answer the 2 [red]red[/red] questions in your code - you are set.

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top