I have a SharePoint list that I export into an Excel sheet. I run a macro that helps me quickly format this list into a printer friendly layout. I have one column though that includes the names of 1 to 6 people that I'm having a hard time formatting. If I have a single name in a cell, it appears as such before I run the macro: "Doe, John E;#28" and I have no problems getting rid of the extrenuous characters so that I only have the person's name left "Doe, John E". I use the following code to accomplish this:
Dim Owner As String
For Each lr In oList.ListRows
Owner = Intersect(lr.Range, oList.ListColumns("Owner").Range).Value
Owner = Replace(Owner, "#", "")
Owner = Replace(Owner, ";", "")
Owner = Replace(Owner, "1", "")
Owner = Replace(Owner, "2", "")
Owner = Replace(Owner, "3", "")
Owner = Replace(Owner, "4", "")
Owner = Replace(Owner, "5", "")
Owner = Replace(Owner, "6", "")
Owner = Replace(Owner, "7", "")
Owner = Replace(Owner, "8", "")
Owner = Replace(Owner, "9", "")
Owner = Replace(Owner, "0", "")
Intersect(lr.Range, oList.ListColumns("Owner").Range).Value = Owner
Next lr
The problem I run into is when I have more than one name in the cell and this information appears as such before I run the macro: "Doe, John E;#34;#Doe, Jane;#152;#Doe, Jim A;#158". After I run the macro, the information in this cell would then appear as such "Doe, John EDoe, JaneDoe, Jim A". You'll notice that there is now no space between the different names. What I would like to do is delete the odd numbered semi-colons (as is currently happening), but replace the even numbered semi-colons with a new line (vbNewLine). Any help with the code that will allow me to do this would be greatly appreciated!
-Adrian-
Dim Owner As String
For Each lr In oList.ListRows
Owner = Intersect(lr.Range, oList.ListColumns("Owner").Range).Value
Owner = Replace(Owner, "#", "")
Owner = Replace(Owner, ";", "")
Owner = Replace(Owner, "1", "")
Owner = Replace(Owner, "2", "")
Owner = Replace(Owner, "3", "")
Owner = Replace(Owner, "4", "")
Owner = Replace(Owner, "5", "")
Owner = Replace(Owner, "6", "")
Owner = Replace(Owner, "7", "")
Owner = Replace(Owner, "8", "")
Owner = Replace(Owner, "9", "")
Owner = Replace(Owner, "0", "")
Intersect(lr.Range, oList.ListColumns("Owner").Range).Value = Owner
Next lr
The problem I run into is when I have more than one name in the cell and this information appears as such before I run the macro: "Doe, John E;#34;#Doe, Jane;#152;#Doe, Jim A;#158". After I run the macro, the information in this cell would then appear as such "Doe, John EDoe, JaneDoe, Jim A". You'll notice that there is now no space between the different names. What I would like to do is delete the odd numbered semi-colons (as is currently happening), but replace the even numbered semi-colons with a new line (vbNewLine). Any help with the code that will allow me to do this would be greatly appreciated!
-Adrian-