Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Move line as Worksheet change not working correctly

Hi,

I have the following code that I found at
http://www.eggheadcafe.com/community...5/cut-row.aspx

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.AddressLocal(ColumnAbsolute:=False), 1) = "M" Then
InsPos = Sheets("Archive").Range("a65536").End(xlUp).Row + 1
Rows(Target.Row).Copy Sheets("Archive").Rows(InsPos)
Rows(Target.Row).Delete shift:=xlUp
End If
End Sub

This works when I enter a value in column "M", but if I chnage the reference
to column AH it does not work (nothing happens at all, no errors, no
cut-and-past).

CAn anyone explain why this is happening (so that I understand) and et me
know how to modify the code so that the cut-and-paste happens when a value is
entered in column AH?

TIA

Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Move line as Worksheet change not working correctly

This is surely because in the Left() function you're looking at the first
character only, which can never be equal to "AH".
Why not use:
If Target.column = 13 ... [or for AH, 34]


"Risky Dave" wrote:

Hi,

I have the following code that I found at
http://www.eggheadcafe.com/community...5/cut-row.aspx

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.AddressLocal(ColumnAbsolute:=False), 1) = "M" Then
InsPos = Sheets("Archive").Range("a65536").End(xlUp).Row + 1
Rows(Target.Row).Copy Sheets("Archive").Rows(InsPos)
Rows(Target.Row).Delete shift:=xlUp
End If
End Sub

This works when I enter a value in column "M", but if I chnage the reference
to column AH it does not work (nothing happens at all, no errors, no
cut-and-past).

CAn anyone explain why this is happening (so that I understand) and et me
know how to modify the code so that the cut-and-paste happens when a value is
entered in column AH?

TIA

Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Move line as Worksheet change not working correctly

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 34 Then Exit Sub 'col AH is col 34
With Sheets("archive")
lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1
Rows(Target.Row).Cut .Rows(lr)
Rows(Target.Row).Delete
End With
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Risky Dave" wrote in message
...
Hi,

I have the following code that I found at
http://www.eggheadcafe.com/community...5/cut-row.aspx

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.AddressLocal(ColumnAbsolute:=False), 1) = "M" Then
InsPos = Sheets("Archive").Range("a65536").End(xlUp).Row + 1
Rows(Target.Row).Copy Sheets("Archive").Rows(InsPos)
Rows(Target.Row).Delete shift:=xlUp
End If
End Sub

This works when I enter a value in column "M", but if I chnage the
reference
to column AH it does not work (nothing happens at all, no errors, no
cut-and-past).

CAn anyone explain why this is happening (so that I understand) and et me
know how to modify the code so that the cut-and-paste happens when a value
is
entered in column AH?

TIA

Dave


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Move line as Worksheet change not working correctly

aardvark & Don

My thanks - fixed

"Don Guillett" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 34 Then Exit Sub 'col AH is col 34
With Sheets("archive")
lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1
Rows(Target.Row).Cut .Rows(lr)
Rows(Target.Row).Delete
End With
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Risky Dave" wrote in message
...
Hi,

I have the following code that I found at
http://www.eggheadcafe.com/community...5/cut-row.aspx

Private Sub Worksheet_Change(ByVal Target As Range)
If Left(Target.AddressLocal(ColumnAbsolute:=False), 1) = "M" Then
InsPos = Sheets("Archive").Range("a65536").End(xlUp).Row + 1
Rows(Target.Row).Copy Sheets("Archive").Rows(InsPos)
Rows(Target.Row).Delete shift:=xlUp
End If
End Sub

This works when I enter a value in column "M", but if I chnage the
reference
to column AH it does not work (nothing happens at all, no errors, no
cut-and-past).

CAn anyone explain why this is happening (so that I understand) and et me
know how to modify the code so that the cut-and-paste happens when a value
is
entered in column AH?

TIA

Dave



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
Change worksheet, two trigger cells on one worksheet, only one triggers correctly; using two If statements, do I need End If? Harold Good Excel Programming 3 March 25th 09 03:37 PM
how do i change the top line of worksheet? sahara Excel Discussion (Misc queries) 4 February 7th 09 07:22 PM
Worksheet change: move to next cell SFC Traver Excel Programming 3 January 10th 08 08:24 PM
Excel 2002 : How to move to the last line of the active worksheet Mr. Low Excel Discussion (Misc queries) 9 December 15th 06 11:37 PM
Change position of move or copy worksheet option in Excel JesseAviles Excel Discussion (Misc queries) 1 February 22nd 05 10:25 PM


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

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

About Us

"It's about Microsoft Excel"