the magician
Active Member
- Joined
- Nov 9, 2006
- Messages
- 496
Why use code tags? Using code tags makes it much easier to read your code, because without them, your code looks like this:
Sub SplitNameWithInstrrevJoinJr()
Dim c As Range, i As Integer
Dim first As String, last As String
For Each c In Range("A1:A" & Range("A65536").End(xlUp).Row)
If Trim(c.Offset(, 3)) = "III" Or Trim(c.Offset(, 3)) = "Jr." Then
i = InStrRev(c, " ")
If i > 0 Then
first = Trim(Left(c, i))
last = Trim(Mid(c, i)) & " " & Trim(c.Offset(, 3))
c = first
c.Offset(, 3) = last
Else
c = first & " " & last
End If
End If
Next
End Sub
YUCK!
With code tags, it looks like this:
Much better, don't you agree????
Using code tags is easy. Either paste your code into the message window, then highlight it (drag-select it) and click the "Code" button (you'll see it just above the "Normal" drop-down for Font Settings). Or if you want to, you can just type in a bracket, the word code, and another bracket at the beginning of the your code sample, and then a bracket, /code, and a closing bracket at the end. Like this:
[/code]
Now the gang will take over the discussion from here with some lively banter and a few more examples of how and how not to post code, depending on your musicianship.
Sub SplitNameWithInstrrevJoinJr()
Dim c As Range, i As Integer
Dim first As String, last As String
For Each c In Range("A1:A" & Range("A65536").End(xlUp).Row)
If Trim(c.Offset(, 3)) = "III" Or Trim(c.Offset(, 3)) = "Jr." Then
i = InStrRev(c, " ")
If i > 0 Then
first = Trim(Left(c, i))
last = Trim(Mid(c, i)) & " " & Trim(c.Offset(, 3))
c = first
c.Offset(, 3) = last
Else
c = first & " " & last
End If
End If
Next
End Sub
YUCK!
With code tags, it looks like this:
Code:
Sub SplitNameWithInstrrevJoinJr()
Dim c As Range, i As Integer
Dim first As String, last As String
For Each c In Range("A1:A" & Range("A65536").End(xlUp).Row)
If Trim(c.Offset(, 3)) = "III" Or Trim(c.Offset(, 3)) = "Jr." Then
i = InStrRev(c, " ")
If i > 0 Then
first = Trim(Left(c, i))
last = Trim(Mid(c, i)) & " " & Trim(c.Offset(, 3))
c = first
c.Offset(, 3) = last
Else
c = first & " " & last
End If
End If
Next
End Sub
Much better, don't you agree????
Using code tags is easy. Either paste your code into the message window, then highlight it (drag-select it) and click the "Code" button (you'll see it just above the "Normal" drop-down for Font Settings). Or if you want to, you can just type in a bracket, the word code, and another bracket at the beginning of the your code sample, and then a bracket, /code, and a closing bracket at the end. Like this:
Code:
[code]Your code here
Now the gang will take over the discussion from here with some lively banter and a few more examples of how and how not to post code, depending on your musicianship.