Hello Xx7,
This will ask you to select the range of cells to truncate.
Sub TruncateRange()
Dim Cell As Range
Dim Lcount As Integer
Dim Rng As Range
Dim NewText As String
Dim Rcount As Integer
Dim Response As Variant
Dim Text As String
Response = InputBox("Enter the number of characters to remove from the left.")
Lcount = Val(Response)
If Lcount = 0 Then Exit Sub
Response = InputBox("Enter the number of characters to remove from the right.")
Rcount = Val(Response)
If Rcount = 0 Then Exit Sub
On Error Resume Next
Set Rng = Application.InputBox("Select the cells you want to truncate.", Type:=8)
If Err <> 0 Then Exit Sub
For Each Cell In Rng
Text = Cell.Text
If Text <> "" Then
NewText = Mid(Text, Lcount + 1, Len(Text) - Lcount)
NewText = Mid(NewText, 1, Len(NewText) - Rcount)
End If
Cell.Offset(0, 1).Value = NewText
Next Cell
End Sub
Bookmarks