#### Danielle005

##### New Member

- Joined
- Jun 24, 2012

- Messages
- 3

This is my first post so I apologise in advance if I do something wrong!

I am very much a novice VBA user. I've been teaching it to myself so I can use it for my honours year thesis.

I'm not sure if I have done something ridiculous here but I've included my code so you all can see. I keep getting multiple errors with this code. One of these is the Compile Error: Else without If and yet there is definitely an If for the Else! I also get another compile error: Expected: Expression. And one more Compile Error: End If without block If

What I am trying to do if build in an error

Any help would be much appreciated!

If Pref(Lp) = 1 Then _

Do

x(tgt) = InputBox(Str8 & Preferred & " to a " & NotPreferred & "." & vbNewLine & vbNewLine & Str12 & Str13 & Str14)

If x(tgt) < geom Or x(tgt) > x(y(Lp, 2)) Then _

MsgBox ("Your answer is invalid. Please ensure that you enter a value between" & geom & " and " & x(y(Lp, 2)))

Loop Until x(tgt) > geom And x(tgt) < x(y(Lp, 2))

Else

Do

x(tgt) = InputBox(Str8 & Preferred & " to a " & NotPreferred & "." & vbNewLine & vbNewLine & Str12 & Str13 & Str14)

If x(tgt) < x(y(Lp, 1)) Or x(tgt) > geom Then

MsgBox ("Your answer is invalid. Please ensure that you enter a value between" & x(y(Lp, 1)) & " and " & geom)

Loop Until x(tgt) > x(y(Lp, 1)) And x(tgt) < geom

End If