Copy and Paste from excel tab to next available row in another tab, macro button code

weurim

New Member
Joined
Apr 1, 2014
Messages
1
I am new to macros/VBA and I am trying to get a solution for mundane copy and paste from and to different worksheets in an excel file. This is to streamline making estimates and Invoices for an electrical contracting company.
In the excel file (see link) I want to have a button in the Materials tab in row J that is clicked that will put A4:D4 in to the next available line on the Inv tab (a quantity is entered first). Then the quantity entered is removed.
For example- in Materials tab quantity 12 is entered on A7, button on J7 is clicked which enters values A7:D7 into next available line (say A23:d23 in linked file) and also removes the quantity 12 from A7 in the Materials tab.
Ideally it would have buttons for adding from materials tab to Inv or Estimate. From Address to Inv, Estimate, and envelope. From tax to inv.
If someone can help with the macro code and how it would be changed for different cells/tabs I could do the rest.
Thank you for any help.
https://www.dropbox.com/s/ynas6zpyjttp4cw/Company test.xlsm
 
Hi weurim,

You really do not need a button on every row.
This Change_Event macro will act if you enter a number in column A.

Copy and paste this in the Materials module.
Copies to Estimate and Inv, but I saw no place on the other sheets where you might want the data to go.

Regards,
Howard


Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
Application.EnableEvents = False

Target.Resize(1, 4).Copy
Sheets("Estimate").Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues
Sheets("Inv").Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues
Target.ClearContents

Application.EnableEvents = True
End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top