LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default IF THEN ELSEIF - newbie needs help

Hi all

I am trying to learn as I go and desperately hoping someone can help
me...First I will explain what I want the program to do, then I will
paste my code....(which is not working : ))

What I want is this: If Cell A2 contains the value 2, and cell e5 is
null, then cell A15 should contain nothing.

But...if cell a2 contains 2 and cell e5 is greater than 84999 or less
than 12000, cell A15 should display "Error"

This will go on for about 4 or 5 cells (e6, e7, e8, etc.) The first
part of it is ok, I am having trouble with the ElseIf. Everytime I
think I get it (and I have looked at some samples on the web), it is
not right and I can't seem to figure out what I am doing wrong. Would
appreciate anyone helping...I think I should say that I would not ever
consider asking anyone to write code for me...i know the value of that
knowledge...but I am trying to teach myself and just would like some
guidance....Thanks!

This is my code:

Sub Test2()
If Range("a1") = 2 Then
If Range("e5") = "" Then Range("a15") = ""
ElseIf Range("e5") 849999 Then Range("a15") = "Error"
Else: Range("a15") = ""
End If
ElseIf Range("e5") < 120000 Then Range("a15") = "Error"
Else: Range("a15") = ""
End If
End Sub

 
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
Elseif? ibrokit Excel Worksheet Functions 5 November 25th 08 04:28 PM
IF..Then..ELSE.. ELSEIF ole_ Excel Programming 4 April 20th 05 03:59 PM
If, ElseIf mast Excel Programming 1 January 26th 05 12:11 PM
ElseIf tom1646 Excel Programming 4 October 19th 04 02:09 PM
If...Elseif...End If javab98 Excel Programming 2 July 19th 04 07:23 PM


All times are GMT +1. The time now is 04:24 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"