Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What would be the correct syntax of inserting a specific number of rows below
the active cell? For instance 4 or 5 rows? -- Thanx in advance, Best Regards, Faraz |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Faraz,
Try the following. Note that a space and underscore at the end of a line is a line break in an otherwise single line of code. Range(ActiveCell.Offset(1, 0), _ ActiveCell.Offset(5, 0)) _ .EntireRow.Insert -- Regards, OssieMac "Faraz A. Qureshi" wrote: What would be the correct syntax of inserting a specific number of rows below the active cell? For instance 4 or 5 rows? -- Thanx in advance, Best Regards, Faraz |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OK!
So there is no direct way and I shall be required to use Offset(). -- Thanx again, Best Regards, Faraz "OssieMac" wrote: Hi Faraz, Try the following. Note that a space and underscore at the end of a line is a line break in an otherwise single line of code. Range(ActiveCell.Offset(1, 0), _ ActiveCell.Offset(5, 0)) _ .EntireRow.Insert -- Regards, OssieMac "Faraz A. Qureshi" wrote: What would be the correct syntax of inserting a specific number of rows below the active cell? For instance 4 or 5 rows? -- Thanx in advance, Best Regards, Faraz |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is a little more direct..
ActiveCell.Offset(1).Resize(4).EntireRow.Insert You seem hesitant about using Offset for some reason, although I'm not sure why. You can do it without using Offset like this... Cells(ActiveCell.Row + 1, 1).Resize(4).EntireRow.Insert but, quite frankly, I would just use the first method and be done with it. -- Rick (MVP - Excel) "Faraz A. Qureshi" wrote in message ... OK! So there is no direct way and I shall be required to use Offset(). -- Thanx again, Best Regards, Faraz "OssieMac" wrote: Hi Faraz, Try the following. Note that a space and underscore at the end of a line is a line break in an otherwise single line of code. Range(ActiveCell.Offset(1, 0), _ ActiveCell.Offset(5, 0)) _ .EntireRow.Insert -- Regards, OssieMac "Faraz A. Qureshi" wrote: What would be the correct syntax of inserting a specific number of rows below the active cell? For instance 4 or 5 rows? -- Thanx in advance, Best Regards, Faraz |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanx Rick!
It's not actually that I am hesitant. I just was eager 2 know if there could be direct way for the purpose of knowledge. -- Thanx again buddy, Best Regards, Faraz "Rick Rothstein" wrote: This is a little more direct.. ActiveCell.Offset(1).Resize(4).EntireRow.Insert You seem hesitant about using Offset for some reason, although I'm not sure why. You can do it without using Offset like this... Cells(ActiveCell.Row + 1, 1).Resize(4).EntireRow.Insert but, quite frankly, I would just use the first method and be done with it. -- Rick (MVP - Excel) "Faraz A. Qureshi" wrote in message ... OK! So there is no direct way and I shall be required to use Offset(). -- Thanx again, Best Regards, Faraz "OssieMac" wrote: Hi Faraz, Try the following. Note that a space and underscore at the end of a line is a line break in an otherwise single line of code. Range(ActiveCell.Offset(1, 0), _ ActiveCell.Offset(5, 0)) _ .EntireRow.Insert -- Regards, OssieMac "Faraz A. Qureshi" wrote: What would be the correct syntax of inserting a specific number of rows below the active cell? For instance 4 or 5 rows? -- Thanx in advance, Best Regards, Faraz . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
See, this is what happens when you post a message at 3:00 am in the morning
(local time), you get sloppy. That last example I posted works, but using Cells is not the way I should have done it, rather, I should have used Rows directly... Rows(ActiveCell.Row + 1).Resize(4).Insert Because this uses one less function call than either of my prior examples, this would be my preference for use in actual code. -- Rick (MVP - Excel) "Faraz A. Qureshi" wrote in message ... Thanx Rick! It's not actually that I am hesitant. I just was eager 2 know if there could be direct way for the purpose of knowledge. -- Thanx again buddy, Best Regards, Faraz "Rick Rothstein" wrote: This is a little more direct.. ActiveCell.Offset(1).Resize(4).EntireRow.Insert You seem hesitant about using Offset for some reason, although I'm not sure why. You can do it without using Offset like this... Cells(ActiveCell.Row + 1, 1).Resize(4).EntireRow.Insert but, quite frankly, I would just use the first method and be done with it. -- Rick (MVP - Excel) "Faraz A. Qureshi" wrote in message ... OK! So there is no direct way and I shall be required to use Offset(). -- Thanx again, Best Regards, Faraz "OssieMac" wrote: Hi Faraz, Try the following. Note that a space and underscore at the end of a line is a line break in an otherwise single line of code. Range(ActiveCell.Offset(1, 0), _ ActiveCell.Offset(5, 0)) _ .EntireRow.Insert -- Regards, OssieMac "Faraz A. Qureshi" wrote: What would be the correct syntax of inserting a specific number of rows below the active cell? For instance 4 or 5 rows? -- Thanx in advance, Best Regards, Faraz . |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() See the following site for a more complex method of inserting rows and keeping formulas. I have not tested it but you might find it interesting. http://www.mvps.org/dmcritchie/excel/insrtrow.htm -- Regards, OssieMac "Faraz A. Qureshi" wrote: OK! So there is no direct way and I shall be required to use Offset(). -- Thanx again, Best Regards, Faraz "OssieMac" wrote: Hi Faraz, Try the following. Note that a space and underscore at the end of a line is a line break in an otherwise single line of code. Range(ActiveCell.Offset(1, 0), _ ActiveCell.Offset(5, 0)) _ .EntireRow.Insert -- Regards, OssieMac "Faraz A. Qureshi" wrote: What would be the correct syntax of inserting a specific number of rows below the active cell? For instance 4 or 5 rows? -- Thanx in advance, Best Regards, Faraz |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2002: Any button to insert blank rows at specific interval? | Excel Discussion (Misc queries) | |||
Insert rows based on specific value | Excel Worksheet Functions | |||
VBA to count rows from specific cell and insert rows | Excel Programming | |||
macros to insert specific rows without altering the formula | Excel Discussion (Misc queries) | |||
finding the number of rows and the first row with a specific value | Excel Programming |