View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Evan_Robitaille via OfficeKB.com Evan_Robitaille via OfficeKB.com is offline
external usenet poster
 
Posts: 2
Default Combine Two Worksheets

Thanks for your help with this, worked like a charm.


Per Jessen wrote:
Hi

Insert the code in "File2", and change file / sheet names as required.

Sub Combine()
Dim wbA As Workbook
Dim wbB As Workbook
Dim shA As Worksheet
Dim shB As Worksheet

Set wbA = ThisWorkbook
Set wbB = Workbooks("File1.xls") 'Change name to suit
Set shA = wbA.Worksheets("Sheet1")
Set shB = wbB.Worksheets("Sheet1")

LastRow = shA.Range("A1").End(xlDown).Row

For r = 2 To LastRow ' Headings in row 1
EndUser = Cells(r, 1).Value
Set f = shB.Columns("A").Find(what:=EndUser, LookAt:=xlWhole)
If Not f Is Nothing Then
shA.Cells(r, 4) = shB.Cells(f.Row, 5).Value
Set f = Nothing
End If
Next
End Sub

Regards,
Per

On 8 Maj, 15:11, "Evan_Robitaille via OfficeKB.com" <u28944@uwe
wrote:
I have two files with the following columns:

[quoted text clipped - 19 lines]
--
Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200905/1


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200905/1