+ Reply to Thread
Results 1 to 2 of 2

Multiple IF statements

  1. #1
    Matt
    Guest

    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. #2
    bpeltzer
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1