View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default How to move records from one folder (tab) to another

The following assumes that by "folder" you mean worksheet. Paste to the
Official List worksheet code module. Minimal testing:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r1 As Range, r2 As Range, c As Range
Dim ws As Worksheet

If Target.Count 1 Then Exit Sub
If Not IsDate(Target.Value) Then Exit Sub
If Not Target.Column = Range("Taken_Date").Column Then Exit Sub
Set c = Cells(Target.Row, 1)
Set r1 = c.Resize(1, 19)
Set ws = Sheets("Delete List")
Set c = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1)
Set r2 = c.Resize(1, 19)
r2.Value = r1.Value
r1.ClearContents
End Sub

Regards,
Greg


"excelnut1954" wrote:

I want to write a macro to move certain records from one folder (tab)
to another. Here are the details:
I have a list of records in a folder named Official List. It's a list
that grows and shrinks in size every day. It extends from column A
through S. When a date is entered in column Q, it means that this
record can be moved to the other folder (named Deleted List), and
placed at the bottom of that list. I have named the header of column Q
"Taken_Date". (I prefer using named ranges, rather than row numbers or
column letters in case I change the design of my spreadsheets)
The range name of the column heading at the top left of the Deleted
List is called "Moved_To"
I hope this is clear enough. As always, I appreciate the help provided
from this group.

ALSO, I've always liked using the If-Then function in my spreadsheets.
But, I'm finding it hard to understand how to use this in VBA. I have a
book by John Walkenback, Power Programing with VBA, but it just doesn't
seem to address this powerful function enough. I've always thought the
If-Then function as a versatile tool, but maybe I'm bypassing better
functions to incorporate into my macros. I've been writing code just
for a few months, so if anyone has a suggestion on good resource
material, I would appreciate it.