Limiting text length
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1" 'edit to suit
Dim cell As Range
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If Len(.Value) 20 Then
Sheets("Sheet2").Range("A1").Value = _
Right(.Value, Len(.Value) - 20)
.Value = Left(.Value, 20)
End If
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
Right-click on the sheet tab and "View Code". Copy/paste the code into that
sheet module.
Edit to suit. Alt + q to return to the Excel window.
Gord
On Sat, 14 Feb 2009 20:32:01 -0800, Steve Edgar
wrote:
Gord,
I would like to know how to move excess text from my cell in the
fist sheet to my second sheet where I already have a cell setup to recieve
it. How is it done?
Thanks
|