View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default AUTOMATIC DATA ENTRY


Try this code. Change Sheet name as required for source workbook. I create
a new sheet in the destination workbook.


Sub CreateMaster()

Set Source = Workbooks("Source.xls")
Set SourceSht = Source.Sheets("Sheet1")

Set Dest = Workbooks("Destination.xls")
'create new worksheet
With Dest
Set DestSht = .Sheets.Add(after:=.Sheets(.Sheets.Count))
End With

With DestSht
SourceSht.Columns("A:A").Copy _
Destination:=.Columns("D:D")
Lastrow = .Range("D" & Rows.Count).End(xlUp).Row

.Range("D1:D" & Lastrow).AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=.Range("C11"), _
Unique:=True

'delete temporay column D
.Columns("D").Delete
.Range("B11") = "MANAGER"
.Range("D11") = "ID"

Lastrow = .Range("C" & Rows.Count).End(xlUp).Row
For RowCount = 12 To Lastrow
Employee = .Range("C" & RowCount)

With SourceSht
Set c = .Columns("A").Find(what:=Employee, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
MsgBox ("Cannot find employee : " & Employee)
Else
Manager = .Range("D" & c.Row)
ID = .Range("B" & c.Row)
End If
End With

If Not c Is Nothing Then
.Range("B" & RowCount) = Manager
.Range("D" & RowCount) = ID
End If
Next RowCount
End With

End Sub


"Bob Bridges" wrote:

This doesn't sound too hard, Kanmi. What have you tried so far? I mean, you
say you need to do this but you don't say what part of it you need help for.
Have you started to write a program to do it, and part of it isn't working
right? Or do you not know how to start?

--- "Kanmi" wrote:
I have a large two workbook (destination.xls and source.xls), that track
training of employee. The source.xls is link to the database such a way that
whenever i open, it pull Automatic update from the database. Manager has
list of employee under him that have undergone the training and these names
sometimes occur more than one time because they have two or more training.
I am trying to set up way that after update pulled by source.xls from the
database should Automatically copies to Destination.xls on a particular rows
and also only pick one name at a time if they appear more than one time"maybe
pick the first occured of each name" and cordinate the name by Manager. For
example

"SOURCE.XLS"
A B C D
A1 EMPLOYEE ID COURSE NAME MANAGER
Kim Bell 002 Sales Training Brian
Kim Bell 002 Safety Training Brian
Lee Paul 003 Light Training Mark
Lee Paul 003 Sales Training Mark.

"DESTINATION.XLS"
B C D
B11 MANAGER EMPLOYEE ID
BRIAN Kim Bell 002
MARK Lee Paul 003

I mean the names should appear on the destination.xls automatically
according to thier MANAGER and each name should appear once on the
destination.xls "sheet1" even if new staff data pulled from database to
source.xls.