spiritbarbie
New Member
- Joined
- May 14, 2018
- Messages
- 3
Hi,
I have a spreadsheet which has a number of formulas. The spreadsheet lists names and payments and I often have to add a high number of new rows but as the sheet is alphabetical not in one place. I have a macro which inserts and new row and copies down the formulas I need but leaves the name section blank.
I have a spreadsheet which has a number of formulas. The spreadsheet lists names and payments and I often have to add a high number of new rows but as the sheet is alphabetical not in one place. I have a macro which inserts and new row and copies down the formulas I need but leaves the name section blank.
Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]Sub AddNewEmployee()[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Dim rw As Long, clAs Long[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Selection.EntireRow.Insert[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] n = ActiveCell.Row[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] For cl = 1 ToColumns.Count[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] If Cells(n -1, cl).HasFormula Then[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Cells(n -1, cl).Copy Cells(n, cl)[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] End If[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Next[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000] Cells(n, 1).Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]End Sub
[code]
I have two problems though. There is a section of the sheet Columns AB and AC and AG to AR which have formulas specific to that employee hat I do not want to copy over, is there a way to amend what I have so these sections are avoided? The second problem is that this does not work is I need to input someone above the existing first entry, how can I alter it so it work in every row?
Thanks :)
[/COLOR][/SIZE][/FONT]