Lost
Assume column A, begining in row 2 in worksheet 3 has an employee IDs and
these IDs can be found in both worksheets 1 and 2 in column A
Dim rng1 as Range, rng2 as Range, rng3 as Range
Dim cell as Range, cell1 as Range, cell2 as Range
Dim res1 as Variant, res2 as Variant
With worksheets("Sheet3")
set rng3 = .Range(.cells(2,1),.cells(rows.count,1).End(xlup))
End with
set rng1 = worksheets("Sheet1").Columns(1).Cells
set rng2 = worksheets("sheet2").Columns(1).Cells
for each cell in rng3
res1 = Application.Match(cell,rng1,0)
res2 = Application.Match(cell,rng2,0)
if not iserror(res1) then
set cell1 = rng1(res1)
cell.offset(0,1).Value = cell1.Offset(0,6).Value
cell.offset(0,2).value = cell1.Offset(0,10).Value
end if
if not iserror(res2) then
set cell2 = rng2(res2)
cell.offset(0,3).Value = cell2.Offset(0,3).Value
cell.offset(0,4).Value = cell2.Offset(0,5).Value
end if
Next
Hopefully this will give you some ideas.
--
Regards,
Tom Ogilvy
"Lost" wrote in message
...
I am looking for some serious help to automate certain tasks in Excel. I
do a
report for a mailroom and I responsible for tracking and updating certain
functions of our department.
Here is the deal, I have three worksheets, worksheet one has the listing
of
all employees information (ie, telephone numbers, building #, etc.) in the
company, worksheet two has all the mailstops for the employees, and
worksheet
three is my report. my goal is to find a way to pull inoformation from
certain rows in worksheet one, and in two and have them placed in three;
basically copy and paste BUT i want it to be automated since i update
worksheet one when people move to new locations.
Does anyone have any suggests? if so, can you also give an example for
reference? (and NO not to do my work! =0)
Thanks!
|