Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


--
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default 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"
wrote in message
news:T.De.Villiers.2bve96_1154450708.7956@excelfor um-nospam.com...

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
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



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