Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() -------------------------------------------------------------------------------- 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do i insert page number on active cell? | Excel Discussion (Misc queries) | |||
Insert a number of rows based on a value in a cell on active row | Excel Discussion (Misc queries) | |||
Insert a number of rows based on a value in a cell on active row | Excel Worksheet Functions | |||
Active Cell plus number of Rows | Excel Programming | |||
Active Cell plus number of Rows | Excel Programming |