Need help adding the same formula multiple times below the last row with data

Cruiser69

Board Regular
Joined
Mar 12, 2018
Messages
68
Office Version
  1. 365
Platform
  1. Windows
Hi all

Could any of you please let me know if this is possible.

The macro below adds the formula 5 times after the last data entry.

Is there a way to shorten it, so the rows 1-5 could be on 1 line.

Code:
[COLOR=#222222][FONT=Verdana]Sub Test()
[/FONT][/COLOR]
[COLOR=#222222][FONT=Verdana]Dim lLastRow AsLong[/FONT][/COLOR]
[COLOR=#222222][FONT=Verdana]With Sheets(1)[/FONT][/COLOR]
[COLOR=#222222][FONT=Verdana]   lLastRow = .Range("K" & .Rows.Count).End(xlUp).Row
    
    .Range("K" & lLastRow + 1).Formula ="=IF(ISFORMULA(RC[1]),""YES"",""NO"")"
    .Range("K" & lLastRow + 2).Formula ="=IF(ISFORMULA(RC[1]),""YES"",""NO"")"
    .Range("K" & lLastRow + 3).Formula ="=IF(ISFORMULA(RC[1]),""YES"",""NO"")"
    .Range("K" & lLastRow + 4).Formula ="=IF(ISFORMULA(RC[1]),""YES"",""NO"")"
    .Range("K" & lLastRow + 5).Formula ="=IF(ISFORMULA(RC[1]),""YES"",""NO"")"[/FONT][/COLOR]


[COLOR=#222222][FONT=Verdana]End With

[/FONT][/COLOR]
[COLOR=#222222][FONT=Verdana]End Sub[/FONT][/COLOR]




Thanks for looking,

Graham


 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try
Code:
    .Range("K" & lLastRow + 1).Resize(5).Formula ="=IF(ISFORMULA(RC[1]),""YES"",""NO"")"
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,219
Members
453,024
Latest member
Wingit77

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