View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default truncating pasted text after 250 characters

Hi
o.k. paste the following code in the worksheetmodule of the specific
worksheet (right-click on the tab name and choose 'Code')
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Intersect(Target, Me.Range("I:I")) Is Nothing Then Exit Sub
On Error GoTo CleanUp:
Application.EnableEvents = False
For Each c In Target
If c.Value < "" Then
c.Value = Left(c.Value, 3)
End If
Next c
CleanUp:
Application.EnableEvents = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany

I need to have the column automatically truncate the data as soon as
it's pasted in column I. I've tried using the sub you posted by
calling it with:

If Not (Intersect(Target, Range("I:I")) Is Nothing) Then
Application.EnableEvents = False
TrimText
End If


The spreadsheet I'm editing is used by a lot of people who don't
understand what macros do, and I want to automate things to avoid any
confusion that might come up. If I called the sub with the above
statement, wouldn't that do the same trick as running the macro
manually after the data is pasted?


---
Message posted from http://www.ExcelForum.com/