
Transfering Data from DATA Sheet
Jim,
You didn't give many specifics about how your data is laid out or
how you have constructed your invoices. Generally you have to
be a little more specific in order to write the code to do something
like this.
One way you might start is to turn on the macro recorder (Tools |
Macro | Record New Macro) and then you can generalize the
code that it writes. The problem with the code from the
macro recorder is that it will record specific cell addresses as you move
about the workbook, and that is frequently a problem for future use of
the macro. For example, when you hit the End Down Arrow keys to
go to the end of the range, the macro recorder will record the
address of the last cell in the range rather than the command End Down.
Here is a web page which will help to deal with issues such as this:
http://www.geocities.com/davemcritchie/excel/recorded.htm
If the invoice is a worksheet and a cell in the row has the invoice
number, you could use some code like this to copy the row
to that worksheet:
Sub CopyRow()
Dim SourceRow As Range
Dim Target As Worksheet
Dim TargetRow As Long
'assume sheetname for target sheet is the value of the activecell
Set Target = Worksheets(ActiveCell.Value)
Set SourceRow = ActiveCell.EntireRow
' Find next blank row in TargetSheet - check using Column A
TargetRow = Target.Cells(Rows.Count, 1).End(xlUp).Row + 1
SourceRow.Copy Destination:=Target.Cells(TargetRow, 1)
End Sub
You don't have to copy and paste the entire row. You can
use the Cells property to be more specific about which cells
to copy and which cell(s) to paste to.
If there are multiple rows to copy, then it is just a matter of writing
a loop to process the desired rows.
HTH,
Brian
Quote:
> Hi, I need to know how to transfer data from my data sheet onto individual
> invoices. Each line of the data sheet pertains to a different account. How do
> I get the data to transfer? I am using Excel 97.
> Thank you,
> Jim