Hi board,
When I enter data into a certain column, I would like the row that the data is entered into to be automatically moved to another sheet. Is this easy to do? Ta.
Hi board,
When I enter data into a certain column, I would like the row that the data is entered into to be automatically moved to another sheet. Is this easy to do? Ta.
This code (when pasted into sheet VB) will copy a row when data is changed in column 5 ("E") and paste it in Sheet3, position A1:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Column = 5 Then
ActiveCell.EntireRow.Copy Sheets("Sheet3").Range("A1")
End If
End Sub
Joel
Sorry for being thick but I can't get it to work. :no:
Right click on the sheet tab where you have your data, and select "view code". paste that function in there!
Thanks for that, it works as it should but it's not quite what I wanted. What I have is a list of items in a cupboard and when I remove an item I put a date in a column next to that item. That item is moved to another sheet so that I have 2 lists. I want to be able to do that automatically.
Does that make sense? :duh:
Not exactly! Can you show sample spreadsheet?
Sorry, don't have example to hand.
What I have is a spreadsheet which is an inventory for stock parts we house in a cupboard. The column headings are - S/N, Item, Supplier and Date. The date is only filled in when the item is taken from the cupboard. I then want that item to be listed on a seperate sheet. At the moment I am doing it manually by cutting and pasting the entire row and I want to be able to do it automatically when the date is filled in.
try this instead:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r1 As Long
If Sheets("Sheet3").Range("A1") <> "" And Sheets("Sheet3").Range("a2") = "" Then
r1 = 1
Else
r1 = Sheets("Sheet3").Cells(1, 1).End(xlDown).Row
If Sheets("Sheet3").Range("A1") = "" Then r1 = 0
End If
If ActiveCell.Column = 4 And ActiveCell.Row > 1 And ActiveCell.Value <> 0 Then
r1 = r1 + 1
ActiveCell.EntireRow.Copy Sheets("Sheet3").Cells(r1, 1)
End If
End Sub
I assume your date is in column "D", other wise change activecell.column number accordingly.
Thanks for your help. Didn't quite work out the way I wanted it. I will look into it further.
It may not have worked exactly what
the filer expected, but this is very helpful to some problem that I had.
Thanx for this.
There is one problem with this code.
When i press enter after entering date
in column D, the code searches for
Active Cell, which is below the one which
i just entered.
E.G. If i have entered Date in D4 and
pressed enter, the cell goes to D5.
At this time the chageselection event is triggered and the active cell D5, if having
date filled in, that row is copied.
Is there any solution?
Thanx in Advance
:o2
Sounds like you have "Move selection after Enter" checked in Tools/Options/Edit. I have mine unchecked. If you want to keep it checked, modify my code to trigger from activecell minus one row!
Finally got it working the way I want but couldn't have done it without your help. Thanx Joel.:D
Don’t have an account yet? Register yourself now and be a part of our community!