Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Nested If Then

If you prefer to compute the value directly in VBA rather than use a formula
try this ....

Sub TimeCode()
Dim lstrow As Long, i As Long, mx As String
lstrow = Cells(Rows.Count, "N").End(xlUp).Row
For i = 1 To lstrow
mx = ""
If IsEmpty(Cells(i, "N")) = False Then
Select Case Cells(i, "N").Value
Case Is 5
mx = "Early"
Case 0 To 5
mx = "OnTime"
Case Is < 0
mx = "Late"
End Select
Cells(i, "O").Value = mx
End If
Next i
End Sub


Cheers
Nigel

"jmdaniel" wrote in message
...
I am trying to return the words "Early, "Late", or "On Time" to a column

of cells, depending on what the value was in the column just to the left. It
worked great when I used the macro recorder to just test for one condition,
and return one of two possibilities, but when I tried to nest all the
possibilities, I get an error on the Active Cell.Formula line. The debug
help isn't, so I thought I would ask if I have this line written correctly.
Thanks!

' Inserts Early, On Time, or Late
Range("N2").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]5,""Early"",IF(RC[-1]=0,""On

Time"",IF(RC[-1]<0,""Late"")))"""
ActiveCell.Offset(1, -1).Select
End If
Loop Until IsEmpty(ActiveCell) = True



Reply
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
Nested IF Help FrankTimJr Excel Discussion (Misc queries) 3 February 6th 10 02:29 AM
Nested if Curtis Excel Worksheet Functions 4 October 6th 09 12:33 AM
Nested If SeanF74 Excel Discussion (Misc queries) 2 September 17th 09 07:21 PM
nested if based on nested if in seperate sheet. how? scouserabbit Excel Worksheet Functions 5 March 2nd 07 04:03 PM
What is quicker? Nested or non nested ifs andycharger[_17_] Excel Programming 2 February 25th 04 03:58 PM


All times are GMT +1. The time now is 05:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"