Inserting rows and copying formulas using macro

Status
Not open for further replies.

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.

Code:
Sub AddNewEmployee()
Dim rw As Long, clAs Long
Selection.EntireRow.Insert
n = ActiveCell.Row
For cl = 1 ToColumns.Count
If Cells(n -1, cl).HasFormula Then
Cells(n -1, cl).Copy Cells(n, cl)
End If
Next
Cells(n, 1).Select
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 [IMG]file:///C:/Users/GABRIE~1/AppData/Local/Temp/msohtmlclip1/01/clip_image001.gif[/IMG]
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Duplicate https://www.mrexcel.com/forum/excel...erting-rows-copying-formulas-using-macro.html

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it.
Please be patient and do not attempt to post the question again.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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