Hello. I am trying to limit the number of characters in an Excel 2010 worksheet created with data imported from another program. Specifically, I need each column to have no more than 30 characters. I have tried the Data Validation technique, but this does not seem to work with imported data, either before or after it's pasted into the worksheet. I have also tried copying a macro (a first for me), as below, but this did not have the desired effect, either:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Excel.Range
If Not Intersect(Target, Columns("A")) Is Nothing Then For Each cell
In Intersect(Target, Columns("A"))
If Len(cell.Value) > 30 Then cell.Value = Left(cell.Value, 30) cell.
Select MsgBox "Truncated to 30 characters"
End If
Next cell
End If
End Sub
If anyone could provide assistance, I would be most grateful.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Excel.Range
If Not Intersect(Target, Columns("A")) Is Nothing Then For Each cell
In Intersect(Target, Columns("A"))
If Len(cell.Value) > 30 Then cell.Value = Left(cell.Value, 30) cell.
Select MsgBox "Truncated to 30 characters"
End If
Next cell
End If
End Sub
If anyone could provide assistance, I would be most grateful.