Solved Excel copy and insert row in new workbook

May 2, 2016 at 23:41:13
Specs: Windows 7
I want to copy a row (A4 to AD4) in workbook "A" sheet2 from a macro button and insert the data into a database in a new work book for my records ,Workbook "B" sheet1.I wish to keep the same format.

message edited by Abd

See More: Excel copy and insert row in new workbook

Report •

May 3, 2016 at 05:05:30
✔ Best Answer
The below code will

copy range A4:AD4
Create a new workbook
Paste the code into sheet1 range A1
Save the new workbook to C:\ drive

You can add a button to your workbook and add this code behind it

Dim NewWB As Workbook

Sub CopyData()
    Set NewWB = Workbooks.Add
    Range("A4:AD4").Copy Destination:=NewWB.Sheets("Sheet1").Range("A1")
    NewWB.SaveAs Filename:="C:\NewWorkbook.xlsx"
End Sub

Report •
Related Solutions

Ask Question