Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert a number of rows based on a value in a cell on active row


--------------------------------------------------------------------------------

Hey all. I am new to macros in excel. Hoping to find help. I have a
worksheet, 3 columns and lets say 1000 rows. Column A is a beginning
page number of a document, column B is its ending page number, and
column C is the number of pages calculated by subtracting Bx - Ay and
adding 1. Example:

...
1000 1001 1
1002 1005 4
1006 1007 2
1008 1008 1
...

I'd like to have a macro which would go line-by-line and insert an
appropriate number of rows in between so I can flesh-out the ranges of
values. Example result would be:

1000 1001 1

1002 1005 4



1006 1007 2

1008 1008 1


Any help would be greatly appreciated.


--
iRocco
------------------------------------------------------------------------
iRocco's Profile: http://www.excelforum.com/member.php...o&userid=26147
View this thread: http://www.excelforum.com/showthread...hreadid=394734

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Insert a number of rows based on a value in a cell on active row

Something like this?

Option Explicit
Sub testme01()

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long

With ActiveSheet
FirstRow = 2 'headers in row 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
If IsNumeric(.Cells(iRow, "C").Value) Then
.Rows(iRow + 1).Resize(.Cells(iRow, "C").Value).Insert
End If
Next iRow
End With
End Sub



iRocco wrote:

--------------------------------------------------------------------------------

Hey all. I am new to macros in excel. Hoping to find help. I have a
worksheet, 3 columns and lets say 1000 rows. Column A is a beginning
page number of a document, column B is its ending page number, and
column C is the number of pages calculated by subtracting Bx - Ay and
adding 1. Example:

..
1000 1001 1
1002 1005 4
1006 1007 2
1008 1008 1
..

I'd like to have a macro which would go line-by-line and insert an
appropriate number of rows in between so I can flesh-out the ranges of
values. Example result would be:

1000 1001 1

1002 1005 4

1006 1007 2

1008 1008 1

Any help would be greatly appreciated.

--
iRocco
------------------------------------------------------------------------
iRocco's Profile: http://www.excelforum.com/member.php...o&userid=26147
View this thread: http://www.excelforum.com/showthread...hreadid=394734


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert a number of rows based on a value in a cell on active row


Thanks Dave. That's pretty awesome. Only two things: The files don'
generally have header rows, and the page counts in column 3 ar
inclusive of the beginning value, so the macro would need to subtract
from the value in column C to determine how many rows to add

--
iRocc
-----------------------------------------------------------------------
iRocco's Profile: http://www.excelforum.com/member.php...fo&userid=2614
View this thread: http://www.excelforum.com/showthread.php?threadid=39473

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Insert a number of rows based on a value in a cell on active row

Glad you got it working after the tweaks.

iRocco wrote:

Thanks Dave. That's pretty awesome. Only two things: The files don't
generally have header rows, and the page counts in column 3 are
inclusive of the beginning value, so the macro would need to subtract 1
from the value in column C to determine how many rows to add.

--
iRocco
------------------------------------------------------------------------
iRocco's Profile: http://www.excelforum.com/member.php...o&userid=26147
View this thread: http://www.excelforum.com/showthread...hreadid=394734


--

Dave Peterson
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
how do i insert page number on active cell? gendut Excel Discussion (Misc queries) 1 August 14th 08 04:18 AM
Insert a number of rows based on a value in a cell on active row iRocco Excel Discussion (Misc queries) 1 August 11th 05 06:18 AM
Insert a number of rows based on a value in a cell on active row iRocco Excel Worksheet Functions 0 August 10th 05 08:46 PM
Active Cell plus number of Rows L. Howard Kittle[_2_] Excel Programming 1 July 14th 03 09:09 PM
Active Cell plus number of Rows Don Guillett[_4_] Excel Programming 0 July 14th 03 08:53 PM


All times are GMT +1. The time now is 06:01 PM.

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"