Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default Multiple IF statements

I have the following

Set iSect = Application.Intersect(Range("UserName"), Target)
If Not iSect Is Nothing Then
For Each tCell In iSect
If tCell.Value < UCase(tCell.Value) Then
tCell.Value = UCase(tCell.Value)

If Len(Trim(tCell.Value)) = 0 Then tCell.Value = "Enter Name"
If Len(Trim(tCell.Value)) = 0 Then Call DefaultValueMsg
End If

Next
End If

How can I correct this so the last two IF statements work. The first
portion works fine.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Multiple IF statements

I'll assume that by 'work', you mean that both 'then' clauses get executed.
As it's set up, when you put "Enter Name" in the cell, you guarantee that the
next test (length = 0) will fail. Set it so that you only make the decision
once, executing both statements if the length is 0:
If Len(Trim(tCell.Value)) = 0 Then
tCell.Value = "Enter Name"
Call DefaultValueMsg
End iF
(That all replaces the two lines that begin if len(trim(tcell.value)) = 0).

"Matt" wrote:

I have the following

Set iSect = Application.Intersect(Range("UserName"), Target)
If Not iSect Is Nothing Then
For Each tCell In iSect
If tCell.Value < UCase(tCell.Value) Then
tCell.Value = UCase(tCell.Value)

If Len(Trim(tCell.Value)) = 0 Then tCell.Value = "Enter Name"
If Len(Trim(tCell.Value)) = 0 Then Call DefaultValueMsg
End If

Next
End If

How can I correct this so the last two IF statements work. The first
portion works fine.

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
Multiple IF statements looking up multiple ranges. mike Excel Worksheet Functions 7 August 9th 07 04:55 PM
Multiple AND & OR statements [email protected] Excel Worksheet Functions 6 May 17th 07 06:22 AM
Multiple if statements I think DP7 Excel Worksheet Functions 2 January 30th 07 05:16 PM
Multiple if statements with multiple conditions egarcia Excel Discussion (Misc queries) 4 January 29th 07 10:46 PM
How to: Multiple "if" statements? Hosh New Users to Excel 2 June 29th 05 02:20 PM


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