I'm taking over a spreadsheet made by someone else. The person is not contactable for assistance. I have a table that spans from A4:W514 and is called "CheckbookTable". I need a macro to create a new line in the table, but each new line needs to have a new and unique PO# in column L as well as copying the format from the above cell. I fount this macro online:
Sub Insert_New_Rows()
Dim Lr As Integer
Lr = Range("A" & Rows.Count).End(xlUp).Row 'Searching last row in column A
Rows(Lr + 1).Insert Shift:=xlDown 'Inserting new row
Cells(Lr + 1, "L") = Cells(Lr, "L") + 1 'Adding a sequential number
Rows(Lr).Copy 'Copying format of last row
Rows(Lr + 1).PasteSpecial Paste:=xlPasteFormats 'Pasting format to new row
Application.CutCopyMode = False 'Deactivating copy mode
End Sub
Problem is my associates and I will be filtering and sorting this table all kinds of ways and if the sort is not by PO# I will add 1 to the wrong PO# resulting in duplicate PO#s.
I would ideally like to have the macro use a count function to count the cell rows in the table and then add 15453750100 to the number (15 for 2015, 45375 - our unit, 0101 because that's where the other person started the counting).
Any ideas?
Sub Insert_New_Rows()
Dim Lr As Integer
Lr = Range("A" & Rows.Count).End(xlUp).Row 'Searching last row in column A
Rows(Lr + 1).Insert Shift:=xlDown 'Inserting new row
Cells(Lr + 1, "L") = Cells(Lr, "L") + 1 'Adding a sequential number
Rows(Lr).Copy 'Copying format of last row
Rows(Lr + 1).PasteSpecial Paste:=xlPasteFormats 'Pasting format to new row
Application.CutCopyMode = False 'Deactivating copy mode
End Sub
Problem is my associates and I will be filtering and sorting this table all kinds of ways and if the sort is not by PO# I will add 1 to the wrong PO# resulting in duplicate PO#s.
I would ideally like to have the macro use a count function to count the cell rows in the table and then add 15453750100 to the number (15 for 2015, 45375 - our unit, 0101 because that's where the other person started the counting).
Any ideas?