View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default COPYING ONE ROW TO ANOTHER SHEET AFTER CELL INPUT

I still left a bad code line in there after correcting it in my code module,
I sent you the one from Note Pad. Oh well! It's one of those days.

Your current problem: The way your original posting read was to look for
the words "Code Error" in column G. Apparently you want it to react to any
change in column G. If that is true, then change the following:

If Not Intersect(Target, Range("G6:G" & lr)) Is Nothing Then
If LCase(Target) = "Code Error" Then
Target.EntireRow.copy Sheets("CODE ERROR").Range("A" & lr2)
End If
End If

To:

If Not Intersect(Target, Range("G6:G" & lr)) Is Nothing Then
Target.EntireRow.copy Sheets("CODE ERROR").Range("A" & lr2)
End If

As long as there is data in the target cell of column G, it will run the
macro.



"OfficeMan" wrote:

Thank you for the help, however I have this following code and no error
message but nothing happens once I input on column G

Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Long, lr2 As Long
lr = ActiveSheet.Cells(Rows.Count, 7).End(xlUp).Row
With Sheets("CODE ERROR")
lr2 = .Cells(.Rows.Count, 6).End(xlUp).Row
End With
If Not Intersect(Target, Range("G6:G" & lr)) Is Nothing Then
If LCase(Target) = "Code Error" Then
Target.EntireRow.copy Sheets("CODE ERROR").Range("A" & lr2)
End If

End If

End Sub



"Dave Peterson" wrote:

with sheets("Code error")
lr2 = .cells(.Rows.Count, 6).End(xlUp).Row
End with

OfficeMan wrote:

Thanks -

On this one it's telling me a differnt error

lr2 = Sheets("CODE ERROR").Rows.Count, 6).End(xlUp).Row

On this line it says "Expected end of statement"

"JLGWhiz" wrote:

This one is tested and gets rid of the typos and omissions.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Long, lr2 As Long
lr = ActiveSheet.Cells(Rows.Count, 7).End(xlUp).Row
lr2 = Sheets("CODE ERROR").Rows.Count, 1).End(xlUp).Row
If Not Intersect(Target, Range("G2:G" & lr) Is Nothing Then
If LCase(Target) = "code error" Then
Target.EntireRow.Copy Sheets("CODE ERROR").Range("A" & lr2)
End If
End If
End Sub

"OfficeMan" wrote:

Good Morning!

I have been trying to do this but unfortunately I am not that great with
Macros

I have sheet named ERRORS and on this sheet I have Column A:G
I have sheet name CODE ERROR and on this sheet I have Column A:G just like
the errors sheet.

I want to copy the entire ROW from sheet ERRORS to CODE ERROR each time
Column G on Sheet ERRORS has input "Code Error"

Any help would be appreciated.

Thank you.


--

Dave Peterson