Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default 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
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 statements Valerie Excel Worksheet Functions 2 February 19th 09 03:36 AM
Nested IF statements using AND / OR Joe[_13_] Excel Worksheet Functions 2 February 9th 09 06:14 PM
Help with nested if/or statements Nick Excel Discussion (Misc queries) 8 September 14th 07 03:46 PM
Nested IF statements Karrisac15 New Users to Excel 1 July 19th 07 08:06 PM
what is the max no. of nested Ifs can an If Statements have in EXC StevenE Excel Discussion (Misc queries) 1 June 27th 05 03:03 PM


All times are GMT +1. The time now is 02:35 AM.

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"