Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Nested If statements
Hi
I'm trying to name a .TXT file opened in excel, if cell A2 contains within it's value the words "List........". I was able to name the first "Output1" but on running the code on the another file error 1004 appeared saying I cannot name the file with the same name. Could you explain the error in my code? Or a different method. If Range("A2").Value < "List with Date of Birth" Then ActiveSheet.Name = "Output1" Else If Range("A2").Value < "List of School Card" Then ActiveSheet.Name = "Output2" Else If Range("A2").Value < "List of ATSI Students with " Then ActiveSheet.Name = "Output3" End If End If End If TIA -- Thank you Regards Bob C Using Windows XP Home + Office 2003 Pro |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Nested If statements
Robert
The parameter "<" means "doesn't equal". The way you wrote your arguments in the 3 "If" statements, each is true if A2 is "Doodle". In fact, each of the 3 are True if A2 is anything other than what that "If" statement uses. I can't offer a correction because I don't know what you want to do with those "If" statements. Please post back with the logic you want to use. HTH Otto "Robert Christie" wrote in message ... Hi I'm trying to name a .TXT file opened in excel, if cell A2 contains within it's value the words "List........". I was able to name the first "Output1" but on running the code on the another file error 1004 appeared saying I cannot name the file with the same name. Could you explain the error in my code? Or a different method. If Range("A2").Value < "List with Date of Birth" Then ActiveSheet.Name = "Output1" Else If Range("A2").Value < "List of School Card" Then ActiveSheet.Name = "Output2" Else If Range("A2").Value < "List of ATSI Students with " Then ActiveSheet.Name = "Output3" End If End If End If TIA -- Thank you Regards Bob C Using Windows XP Home + Office 2003 Pro |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Nested If statements
Hi Otto
Thank you for your reply. The parameter I require is If A2 contains the string "List with date...." then name that sheet "Output1". I'm opening three .TXT files which do not indicate in their names what particular student information data they hold, but the A2 cell does. So I would like to check part of A2 content and name the each sheet in order they order of use. The .TXT files are reports generatered from another computer system and are not allways produced in the same order. HTH you understand my requirments. Regards Bob C "Otto Moehrbach" wrote: Robert The parameter "<" means "doesn't equal". The way you wrote your arguments in the 3 "If" statements, each is true if A2 is "Doodle". In fact, each of the 3 are True if A2 is anything other than what that "If" statement uses. I can't offer a correction because I don't know what you want to do with those "If" statements. Please post back with the logic you want to use. HTH Otto "Robert Christie" wrote in message ... Hi I'm trying to name a .TXT file opened in excel, if cell A2 contains within it's value the words "List........". I was able to name the first "Output1" but on running the code on the another file error 1004 appeared saying I cannot name the file with the same name. Could you explain the error in my code? Or a different method. If Range("A2").Value < "List with Date of Birth" Then ActiveSheet.Name = "Output1" Else If Range("A2").Value < "List of School Card" Then ActiveSheet.Name = "Output2" Else If Range("A2").Value < "List of ATSI Students with " Then ActiveSheet.Name = "Output3" End If End If End If TIA -- Thank you Regards Bob C Using Windows XP Home + Office 2003 Pro |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Nested IF statements | Excel Worksheet Functions | |||
Nested IF statements using AND / OR | Excel Worksheet Functions | |||
Help with nested if/or statements | Excel Discussion (Misc queries) | |||
Nested IF statements | New Users to Excel | |||
what is the max no. of nested Ifs can an If Statements have in EXC | Excel Discussion (Misc queries) |