Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Auto Increment Rows in between numbers

Hello.
I have a spreadsheet that has a list of numbers on the left side (Column A)
and I need to know how to create a macro that when I hit a button a row will
insert in between the list of numbers and automatically fill in the number
that goes there. If that makes sense. So if I have a list of 1-20 and I
insert a row between 15 and 16, it will put 16 in that cell and put 21 at the
end of the list. Thanks so much for you help.
--
D
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Auto Increment Rows in between numbers

Try this code...

Public Sub InsertARow()
Dim rngCurrent As Range
Dim rngToFill As Range

Set rngCurrent = Range("A" & ActiveCell.Row)
Set rngToFill = rngCurrent.End(xlDown)

rngCurrent.EntireRow.Insert
Set rngToFill = Range(rngCurrent.Offset(-2, 0), rngToFill)

rngCurrent.Offset(-2, 0).AutoFill rngToFill, xlFillSeries

End Sub

HTH

"D" wrote:

Hello.
I have a spreadsheet that has a list of numbers on the left side (Column A)
and I need to know how to create a macro that when I hit a button a row will
insert in between the list of numbers and automatically fill in the number
that goes there. If that makes sense. So if I have a list of 1-20 and I
insert a row between 15 and 16, it will put 16 in that cell and put 21 at the
end of the list. Thanks so much for you help.
--
D

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Works Excellent

Thank you, works like a charm! That is awewsome.

"Jim Thomlinson" wrote:

Try this code...

Public Sub InsertARow()
Dim rngCurrent As Range
Dim rngToFill As Range

Set rngCurrent = Range("A" & ActiveCell.Row)
Set rngToFill = rngCurrent.End(xlDown)

rngCurrent.EntireRow.Insert
Set rngToFill = Range(rngCurrent.Offset(-2, 0), rngToFill)

rngCurrent.Offset(-2, 0).AutoFill rngToFill, xlFillSeries

End Sub

HTH

"D" wrote:

Hello.
I have a spreadsheet that has a list of numbers on the left side (Column A)
and I need to know how to create a macro that when I hit a button a row will
insert in between the list of numbers and automatically fill in the number
that goes there. If that makes sense. So if I have a list of 1-20 and I
insert a row between 15 and 16, it will put 16 in that cell and put 21 at the
end of the list. Thanks so much for you help.
--
D

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
suspend auto increment Bill Johnson Excel Discussion (Misc queries) 6 February 8th 08 06:26 PM
auto increment Trizzle Excel Discussion (Misc queries) 1 December 6th 06 09:14 PM
DP Auto increment [email protected] Excel Worksheet Functions 2 August 16th 06 12:37 AM
how to make excel auto enter increment invoice numbers. foster1929 Excel Discussion (Misc queries) 1 July 11th 06 03:05 AM
How to auto insert rows in a list of numbers zdek Excel Discussion (Misc queries) 3 June 16th 06 10:19 PM


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

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

About Us

"It's about Microsoft Excel"