Sumeluar
Active Member
- Joined
- Jun 21, 2006
- Messages
- 274
- Office Version
- 365
- 2016
- 2010
- Platform
- Windows
- MacOS
- Mobile
Good day! - I need help on modifying the code below to do the following:
On a named range from columns C to J, I would like to add a bullet only to any text entered on Column D6 and down, if any cells on column D already containing a bullet has to be ignored so not to end up with multiple bullets. The below code came from a google search, it works but the range (Column D) needs to be selected manually and any cells already containing a bullet and the code is reapplied end up with an additional one.
Sub Add_Bullets()
Dim cell As Range
Dim vntLines As Variant
Dim lngIndex As Long
Dim strTemp As String
Sheets("EventsList").Select
For Each cell In Selection.Cells
strTemp = ""
vntLines = Split(cell.Value, vbLf)
For lngIndex = LBound(vntLines) To UBound(vntLines)
If Len(Trim(vntLines(lngIndex))) > 0 Then
strTemp = strTemp & Chr(149) & " " & vntLines(lngIndex) & vbLf
Else
strTemp = strTemp & vbLf
End If
Next
cell.Value = Left(strTemp, Len(strTemp) - 1)
Next cell
End Sub
I appreciate any new suggestions or improvements to the above code.
Best Regards!
On a named range from columns C to J, I would like to add a bullet only to any text entered on Column D6 and down, if any cells on column D already containing a bullet has to be ignored so not to end up with multiple bullets. The below code came from a google search, it works but the range (Column D) needs to be selected manually and any cells already containing a bullet and the code is reapplied end up with an additional one.
Sub Add_Bullets()
Dim cell As Range
Dim vntLines As Variant
Dim lngIndex As Long
Dim strTemp As String
Sheets("EventsList").Select
For Each cell In Selection.Cells
strTemp = ""
vntLines = Split(cell.Value, vbLf)
For lngIndex = LBound(vntLines) To UBound(vntLines)
If Len(Trim(vntLines(lngIndex))) > 0 Then
strTemp = strTemp & Chr(149) & " " & vntLines(lngIndex) & vbLf
Else
strTemp = strTemp & vbLf
End If
Next
cell.Value = Left(strTemp, Len(strTemp) - 1)
Next cell
End Sub
I appreciate any new suggestions or improvements to the above code.
Best Regards!