Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / September 2007

Tip: Looking for answers? Try searching our database.

Getting error using if then else stmt

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ub - 24 Sep 2007 20:56 GMT
Hi
I am using the follwoing code,
For rwIndex 4 to 100
If Month(Worksheets("Sheet1").Cells(rwIndex, 12).Value) > _
  Month(Mydate) Then .Interior.Color = RGB(255, 0, 0)
  ElseIf Month(Worksheets("Sheet1").Cells(rwIndex, 12).Value) = "" Then
Worksheets("Sheet1").Cells(rwIndex, 12).Interior.Color = 2
  Else
  Worksheets("Sheet1").Cells(rwIndex, 12).Interior.Color = 2
  End If

System gives me 'Complie Error'
Else without if.

Please advise, what is wrong with my code
JW - 24 Sep 2007 21:54 GMT
Probably giving you an arbitrary error.  Looks like the real problem
is in you For syntax.
For rwIndex 4 to 100 shoudl be For rwIndex = 4 to 100
> Hi
> I am using the follwoing code,
[quoted text clipped - 11 lines]
>
> Please advise, what is wrong with my code
eliano - 24 Sep 2007 22:48 GMT
Hi ub.
> If Month(Worksheets("Sheet1").Cells(rwIndex, 12).Value) > _
>    Month(Mydate) Then .Interior.Color = RGB(255, 0, 0)
If and Then on the same row, end the IF instruction.

For rwindex = 4 To 100
If Month(Cells(rwindex, 12).Value) > Month(Mydate) Then
 Cells(rwindex, 12).Interior.Color = RGB(255, 0, 0)
  ElseIf Month(Cells(rwindex, 12).Value) = "" Then
   Cells(rwindex, 12).Interior.ColorIndex = 6
    Else
     Cells(rwindex, 12).Interior.ColorIndex = 6
      End If
Next

Regards
Eliano

> Hi
> I am using the follwoing code,
[quoted text clipped - 11 lines]
>
> Please advise, what is wrong with my code
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.