Insert row, copy formulas, increment ID+1

uson

New Member
Joined
May 9, 2011
Messages
27
This forum is so helpful! Thanks to all the pro's helping the newbies.

Our team (multi-users) uses a workbook to track new projects. I would like some code to do the following:
1 - add a button to the worksheet to Add A New Project
2 - the code would find the last project row (there are 3 rows at the bottom with totals, etc) so the last project is NOT the last row but col C is part of a merged cell
3 - look at the last project ID (col C) and add +1
4 - insert the row above the total line and copy the formats, formulas and validations from the row above

Ideas? Thanks so much.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
To add a button, open the form controls toolbar and select the Command Button
Place the button on the screen where you want it, then assign the code below to the button, by right clicking on the button and selecting Assign Macro
There will be better ways but try
Code:
Sub addstuff()
Dim lr As Long, r As Long, val As Range
lr = Cells(Rows.Count, "C").End(xlUp).Row
Set val = Range("C" & lr - 3)
Rows(lr - 3).Copy
Rows(lr - 2).Insert
Rows(lr - 2).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone
    Application.CutCopyMode = False
Range("C" & lr - 2).Value = val + 1
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,603
Messages
6,125,771
Members
449,259
Latest member
rehanahmadawan

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