ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert a row then copy a transaction (https://www.excelbanter.com/excel-programming/334452-insert-row-then-copy-transaction.html)

ledzepe[_2_]

Insert a row then copy a transaction
 

Hello gurus,

Can somebody show me how to create a macro/script that would insert a
row in a worksheet (Sheet1) and then copy the top row of another
worksheet (Sheet2) into the inserted row? The copying needs to
triggered manually.

We have a 4 copy pre-printed form that we use a dot matrix to print to
it and I made an Excel template where the clerk can enter the data and
then just hit print. I am trying to capture the data that the clerk
types in and create a database so we'll a searchable computer record.

If inserting the data in a row is not possible, how about exporting a
row and appending it on a text file?

Thanks in advance.


--
ledzepe
------------------------------------------------------------------------
ledzepe's Profile: http://www.excelforum.com/member.php...o&userid=25207
View this thread: http://www.excelforum.com/showthread...hreadid=386957


Rowan[_2_]

Insert a row then copy a transaction
 
You didn't say where you want to insert the row but I have assumed at row 2
(just below headings).

Sub CopyOver()
Sheets("Sheet1").Range("A2").EntireRow.Insert
Sheets("Sheet2").Rows("1:1").Copy _
Destination:=Sheets("Sheet1").Rows("2:2")
End Sub

Alternately, you may just want to copy the data to the first row which does
not allready have data in column A (i.e. the first blank row):

Sub CopyOver()
Dim endRow As Long
endRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheets("Sheet2").Rows("1:1").Copy _
Destination:=Sheets("Sheet1").Rows(endRow & ":" & endRow)
End Sub

Hope this helps
Rowan


"ledzepe" wrote:


Hello gurus,

Can somebody show me how to create a macro/script that would insert a
row in a worksheet (Sheet1) and then copy the top row of another
worksheet (Sheet2) into the inserted row? The copying needs to
triggered manually.

We have a 4 copy pre-printed form that we use a dot matrix to print to
it and I made an Excel template where the clerk can enter the data and
then just hit print. I am trying to capture the data that the clerk
types in and create a database so we'll a searchable computer record.

If inserting the data in a row is not possible, how about exporting a
row and appending it on a text file?

Thanks in advance.


--
ledzepe
------------------------------------------------------------------------
ledzepe's Profile: http://www.excelforum.com/member.php...o&userid=25207
View this thread: http://www.excelforum.com/showthread...hreadid=386957




All times are GMT +1. The time now is 08:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com