ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Insert A Row Macro (https://www.excelbanter.com/new-users-excel/47867-insert-row-macro.html)

Mark Williams

Insert A Row Macro
 
Hi All,

I am trying to write a macro that will insert a row above a blank row in a
range I've named "PriorPTI". The blank row is the last row in a range that
contains 12 rows. The range will grow as I insert more rows. I am not a
programmer so any help will be greatly appreciated as I've spent two work
days trying to figure this out (Yes: it is rocket science :-)).

Regards,
Mark

Trevor Shuttleworth

Mark

something like:

Range("PriorPTI").Offset(-1, 0).Resize(1).EntireRow.Insert

will insert 1 row in front of the range called PriorPTI

Regards

Trevor


"Mark Williams" <Mark wrote in message
...
Hi All,

I am trying to write a macro that will insert a row above a blank row in a
range I've named "PriorPTI". The blank row is the last row in a range that
contains 12 rows. The range will grow as I insert more rows. I am not a
programmer so any help will be greatly appreciated as I've spent two work
days trying to figure this out (Yes: it is rocket science :-)).

Regards,
Mark




Duke Carey

You're always going to want to add a row just above the last row in the named
range, yes?

DIM rng as Range
Set rng = Range("PriorPTI")
rng.Offset(rng.Rows.Count - 1, 0).Resize(1, 1).EntireRow.Insert xlDown


"Mark Williams" wrote:

Hi All,

I am trying to write a macro that will insert a row above a blank row in a
range I've named "PriorPTI". The blank row is the last row in a range that
contains 12 rows. The range will grow as I insert more rows. I am not a
programmer so any help will be greatly appreciated as I've spent two work
days trying to figure this out (Yes: it is rocket science :-)).

Regards,
Mark



All times are GMT +1. The time now is 03:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com