Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try this code.
Sub lookupbooks() 'this should be workbook a Set wsh1 = ThisWorkbook.Worksheets(1) wsh1.Activate lastrow = wsh1.Cells(Rows.Count, 1).End(xlUp).Row Set InvoiceRange = wsh1.Range(Cells(1, 1), Cells(lastrow, 1)) For Each cell1 In InvoiceRange InvoiceNumber = cell1.Value For Each wbk1 In Application.Workbooks If StrComp(wbk1.Name, ThisWorkbook.Name) < 0 Then With wbk1.Worksheets(1) .Activate lastrow = .Cells(Rows.Count, 10).End(xlUp).Row Set InvoiceRange2 = .Range(Cells(1, 10), Cells(lastrow, 10)) For Each cell2 In InvoiceRange2 If (InvoiceNumber = cell2.Value) Then .Range(Cells(cell2.Row, 1), Cells(cell2.Row, 10)).Copy _ Destination:=wsh1.Cells(cell1.Row, 2) End If Next cell2 End With End If Next wbk1 Next cell1 End Sub "Joe via OfficeKB.com" wrote: I'm trying to figure out the right way of writing this idea, I need some help! ! Ok we start off in wrkbk A and start in cell A1(which is an invoice #) we copy cell A1 and search for the contents of cell A1 in wrkbk B if found copy cell + 9 cells to the left and past to cell M1 in wrkbk A. then Next line repeat same process; if not found go back to wrkbk A and go to the next line and repeat. Oh yeah when it's searching for content of cell A1 the invoice # may be in wrkbk B,C or D... any ideas? -- Message posted via http://www.officekb.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula in Macro | Excel Discussion (Misc queries) | |||
Formula or Macro | Excel Discussion (Misc queries) | |||
Formula in macro causes macro to fail | Excel Programming | |||
Formula Macro | Excel Discussion (Misc queries) | |||
Formula expected end of statement error, typing formula into cell as part of VBA macro | Excel Programming |