View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Jock Jock is offline
external usenet poster
 
Posts: 440
Default Move cell contents along using vba?

That's got it. Thanks very much Steve.
Nice one
--
Traa Dy Liooar

Jock


"Steve Yandl" wrote:

Don't know how I got Application.EnableEvents = True in there twice but it
seemed to work when I tested. Try what I've got below instead.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngTempX As Range
Dim rngTempEnd As Range
Dim rngTempA As Range
Dim rngTempAend
Dim rngTempB As Range
Dim rngTempBend As Range

If Target.Column = 3 Then
Application.EnableEvents = False

If Target.Row 1 Then
If Target.Offset(-1, 0).Text = "" Then
If Not Target.Offset(-1, 1).Text = "" Then
Set rngTempAend = Cells(Target.Row - 1, 256).End(xlToLeft)
Set rngTempA = Range(Target.Offset(-1, 1).Address & ":" &
rngTempAend.Address)
rngTempA.Cut Destination:=Target.Offset(-1, 0)
End If
End If
End If

If Target.Offset(1, 0).Text = "" Then
If Not Target.Offset(1, 1).Text = "" Then
Set rngTempBend = Cells(Target.Row + 1, 256).End(xlToLeft)
Set rngTempB = Range(Target.Offset(1, 1).Address & ":" &
rngTempBend.Address)
rngTempB.Cut Destination:=Target.Offset(1, 0)
End If
End If

If Not Target.Text = "" Then
Set rngTempEnd = Cells(Target.Row, 256).End(xlToLeft)
Set rngTempX = Range(Target.Address & ":" & rngTempEnd.Address)
rngTempX.Cut Destination:=Target.Offset(0, 1)
End If

Application.EnableEvents = True
End If
End Sub