+ Reply to Thread
Results 1 to 3 of 3

Else Without If

  1. #1
    Forum Contributor
    Join Date
    08-20-2005
    Posts
    171

    Else Without If

    Get the above message for this portion of code,
    Many thanks for your help

    Sub leng()

    For i = 14 To 7
    If Len(Cells(4, i)) = 5 Then Cells(4, i) = "J" & Cells(4, i)
    Else
    If Cells(4, i) = 123 Then Cells(4, i) = "R" & Cells(4, i)
    Else
    If Cells(4, i) = 124 Then Cells(4, i) = "R" & Cells(4, i)
    Else
    If Cells(4, i) = 128 Then Cells(4, i) = "R" & Cells(4, i)
    Else
    If Cells(4, i) = 148 Then Cells(4, i) = "R" & Cells(4, i)
    Else
    If Cells(4, i) = 157 Then Cells(4, i) = "R" & Cells(4, i)
    Else
    If Cells(4, i) = 161 Then Cells(4, i) = "Q" & Cells(4, i)
    End If
    Next

    End Sub

  2. #2
    Jim Thomlinson
    Guest

    RE: Else Without If

    Try this...

    Sub leng()
    Dim i As Integer
    For i = 14 To 7 Step -1
    If Len(Cells(4, i)) = 5 Then
    Cells(4, i) = "J" & Cells(4, i)
    ElseIf Cells(4, i) = 123 Then
    Cells(4, i) = "R" & Cells(4, i)
    ElseIf Cells(4, i) = 124 Then
    Cells(4, i) = "R" & Cells(4, i)
    ElseIf Cells(4, i) = 128 Then
    Cells(4, i) = "R" & Cells(4, i)
    ElseIf Cells(4, i) = 148 Then
    Cells(4, i) = "R" & Cells(4, i)
    ElseIf Cells(4, i) = 157 Then
    Cells(4, i) = "R" & Cells(4, i)
    ElseIf Cells(4, i) = 161 Then
    Cells(4, i) = "Q" & Cells(4, i)
    End If
    Next

    End Sub
    --
    HTH...

    Jim Thomlinson


    "T De Villiers" wrote:

    >
    > Get the above message for this portion of code,
    > Many thanks for your help
    >
    > Sub leng()
    >
    > For i = 14 To 7
    > If Len(Cells(4, i)) = 5 Then Cells(4, i) = "J" & Cells(4, i)
    > Else
    > If Cells(4, i) = 123 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 124 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 128 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 148 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 157 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 161 Then Cells(4, i) = "Q" & Cells(4, i)
    > End If
    > Next
    >
    > End Sub
    >
    >
    > --
    > T De Villiers
    > ------------------------------------------------------------------------
    > T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
    > View this thread: http://www.excelforum.com/showthread...hreadid=567130
    >
    >


  3. #3
    Bob Phillips
    Guest

    Re: Else Without If

    Try this

    Sub leng()
    Dim i As Integer
    For i = 14 To 7 Step -1
    Select Case Cells(4, i).Value
    Case 5: Cells(4, i) = "J" & Cells(4, i)
    Case 123, 124, 128, 148, 157: Cells(4, i) = "R" & Cells(4, i)
    Case 161: Cells(4, i) = "Q" & Cells(4, i)
    End Select
    Next

    End Sub


    --

    HTH

    Bob Phillips

    (replace xxxx in the email address with gmail if mailing direct)

    "T De Villiers" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Get the above message for this portion of code,
    > Many thanks for your help
    >
    > Sub leng()
    >
    > For i = 14 To 7
    > If Len(Cells(4, i)) = 5 Then Cells(4, i) = "J" & Cells(4, i)
    > Else
    > If Cells(4, i) = 123 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 124 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 128 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 148 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 157 Then Cells(4, i) = "R" & Cells(4, i)
    > Else
    > If Cells(4, i) = 161 Then Cells(4, i) = "Q" & Cells(4, i)
    > End If
    > Next
    >
    > End Sub
    >
    >
    > --
    > T De Villiers
    > ------------------------------------------------------------------------
    > T De Villiers's Profile:

    http://www.excelforum.com/member.php...o&userid=26479
    > View this thread: http://www.excelforum.com/showthread...hreadid=567130
    >




+ 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