Macro - Search one book, replace with data from another

C

CaymanCarrie

I've exhausted my capabilities after hours of searching through threads.
I've done what I can, but am humbly seeking the advice of the experts. I'm
not very good with VBA and survive by copying tid-bits that I see in other
threads.

I'm developing an invoicing system which is comprised of two separate
workbookss:
1) Invoice Template
2) Invoice Listing

The Invoice template contains a lookup formula to the Invoice Listing to get
the next available invoice number. It also contains code to Paste that
Invoice # as values, then copy an entire row of signficant invoice data (Row
2 of Summary Sheet) to the Invoice Listing.

The Invoice Listing is a simple list of Row 2 of Summary Sheet from every
Invoice that is created.

I need a macro that allows for changes to the invoice data once it's saved
(i.e. extra billable hours, which changes information in Row 2 of Summary
Sheet). I'd like the macro to search for the invoice number from the Invoice
(Cell B1 of Invoice Sheet), search through the Invoice Listing, and replace
the entire row with the new data from Row 2 of Summary Sheet.

The Invoice Template contains the following code (probably totally
inefficient):

Sub AddtoList()

Sheets ("Invoice").Select
Range ("B1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:xlNone,
SkipBlanks_:=False,Transpose:=False

Sheets("Summary").Select
Rows("2:2").Select
Selection.Copy

Workbooks.Open Filename:=_
"M:\ACCTS\TEMPLATES&FORMS\Invoicing\Invoice Listing.xls"
Range ("A1"). Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
Skipblanks_:=False, Transpose:=False
ActiveWorkbook.Save
ActiveWindow.Close
End Sub

Thanks so much for any help that anyone can provide. I'm at my wits end :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top