Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Insert A Row

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Insert A Row

this might be all you need.

Option Explicit

Dim lastrow As Long

Sub insertrow()
lastrow = Cells(Rows.Count, "A").End(xlUp).offset(1,0).Row
Range("a" & lastrow).EntireRow.Insert


End Sub


--


Gary


"Mark Williams" 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Insert A Row

Dim rng as Range
set rng = Range("PriorPTT")
set rng = rng.rows(rng.rows.count)
rng.EntireRow.Insert

--
Regards,
Tom Ogilvy



"Mark Williams" 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Insert A Row

Tom/Gary Thanks for your responses. Tom I copied your macro right into vis.
basic and received the following run time error: 1004 Method 'Range' of
object'_Global' failed. I did add Sub insertrow() before the macro and End
Sub at the end.

Thanks for your help.
Regards,
Mark

"Tom Ogilvy" wrote:

Dim rng as Range
set rng = Range("PriorPTT")
set rng = rng.rows(rng.rows.count)
rng.EntireRow.Insert

--
Regards,
Tom Ogilvy



"Mark Williams" 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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Insert A Row

Tom, Please ignore my previous post. The error was due to incorrect
spelling. Thanks for your help.

Gary, Thank you as well for your time. Its greatly appreciated.

Regards,
Mark

"Tom Ogilvy" wrote:

Dim rng as Range
set rng = Range("PriorPTT")
set rng = rng.rows(rng.rows.count)
rng.EntireRow.Insert

--
Regards,
Tom Ogilvy



"Mark Williams" 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot insert worksheet in exel - not available in insert menu pedro39 Excel Worksheet Functions 1 July 24th 08 12:09 PM
insert row / insert column command buttons fairgreen Excel Worksheet Functions 1 October 29th 07 02:41 PM
Can I auto insert a worksheet when I insert a value in a cell. iainc Excel Worksheet Functions 0 April 27th 06 08:37 AM
Insert Next? Or insert a variable number of records...how? Tom MacKay Excel Discussion (Misc queries) 0 April 20th 06 10:44 PM
Insert cell/format/text/fontsize and auto insert into header? Unfurltheflag Excel Programming 2 November 3rd 04 05:39 PM


All times are GMT +1. The time now is 11:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"