Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Move cell contents with macro Peridot Excel Discussion (Misc queries) 4 September 30th 09 03:35 PM
Move cell contents to another column IF Scott Wagner Excel Programming 2 February 17th 06 07:21 PM
move cell contents David L Excel Discussion (Misc queries) 13 November 24th 05 08:18 PM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
How to move cell contents Stephane Excel Discussion (Misc queries) 6 January 13th 05 12:49 AM


All times are GMT +1. The time now is 12:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"