View Full Version : Troublesome If Then Else statement


scott-atkinson
01-11-2008, 04:33 AM
Guys,

Wonder if you could offer some assistance please, I am trying to code an If Then statement to compare values of a cell in different worksheets and then act on the result. But it does not work, when running it just steps over the statement and runs both scenerios.

My code:

If Sheets("additive").Range("j7") < Sheets("multiplicative").Range("j7") Then GoTo Line1 Else
Application.Run "'Forecasting Module.v2 Poundland.xls'!Load_Multi"

Line1:
Application.Run "'Forecasting Module.v2 Poundland.xls'!Load_Addit"

What am I doing wrong?

Brianwarnock
01-11-2008, 04:42 AM
From a logic point of view it should not run both if the result is < but will run both for > or =.

If Sheets("additive").Range("j7") < Sheets("multiplicative").Range("j7") Then Application.Run "'Forecasting Module.v2 Poundland.xls'!Load_Addit"
Else
Application.Run "'Forecasting Module.v2 Poundland.xls'!Load_Multi"
Endif

Might work

Brian