Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting # of rows depending on value in Column

I have a spreadsheet where I need to insert x number of
rows below the row where the column = "x" For ex.

A B C D
abc 123 xyz 3 I need excel to insert 3 rows beneath
this row.

Any help is appreciated, because I'm not having much luck!

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Inserting # of rows depending on value in Column

Assume the cell with xyz is selected

x = 3
ActiveCell.offset(1,0).Resize(x,1).EntireRow.Inser t

--
Regards,
Tom Ogilvy

Christel wrote in message
...
I have a spreadsheet where I need to insert x number of
rows below the row where the column = "x" For ex.

A B C D
abc 123 xyz 3 I need excel to insert 3 rows beneath
this row.

Any help is appreciated, because I'm not having much luck!

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Inserting # of rows depending on value in Column

Sorry, I should have been more specific. I need to go
through rows 2 to 1000, checking each column 11 for the
value that I need to insert that number of rows under.
I have this and it "kind of" works, but it inserts the
rows in the wrong place. Any more suggestions? Thanks!

Sub addrows()
Dim intCol As Integer
Dim intRow As Integer
For intRow = 3 To 1000
intCol = 11
If Worksheets("Master Schedule").Cells(intRow,
intCol).Value < "" Then
Rowinsert = Value
ActiveCell.Offset(1, 0).EntireRow.Insert
intRow = intRow + 1


-----Original Message-----
Assume the cell with xyz is selected

x = 3
ActiveCell.offset(1,0).Resize(x,1).EntireRow.Inse rt

--
Regards,
Tom Ogilvy

Christel wrote in

message
...
I have a spreadsheet where I need to insert x number of
rows below the row where the column = "x" For ex.

A B C D
abc 123 xyz 3 I need excel to insert 3 rows

beneath
this row.

Any help is appreciated, because I'm not having much

luck!

Thanks!



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Inserting # of rows depending on value in Column

I should also mention that Column 11 is a formula that
calculates a number

-----Original Message-----
Assume the cell with xyz is selected

x = 3
ActiveCell.offset(1,0).Resize(x,1).EntireRow.Inse rt

--
Regards,
Tom Ogilvy

Christel wrote in

message
...
I have a spreadsheet where I need to insert x number of
rows below the row where the column = "x" For ex.

A B C D
abc 123 xyz 3 I need excel to insert 3 rows

beneath
this row.

Any help is appreciated, because I'm not having much

luck!

Thanks!



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Inserting # of rows depending on value in Column

Building on Tom's answer and your own macro... try:

Sub AddRows()
Dim intRow As Integer
Dim strValue As String
Dim intNumRows As Integer
Dim rng As Range

For intRow = 3 To 1000
Set rng = Worksheets("Master Schedule").Cells(intRow, 11)
strValue = rng.Value
If strValue < "" And IsNumeric(strValue) Then
intNumRows = CInt(strValue)
rng.Offset(1, 0).Resize(intNumRows, 1).EntireRow.Insert
End If
Next intRow

End Sub

Please note that when you use the for/next statement, you don't need to
increment your counter -- ie you don't need to do intRow = intRow + 1

--
HTH,
Dianne
In ,

typed:
Sorry, I should have been more specific. I need to go
through rows 2 to 1000, checking each column 11 for the
value that I need to insert that number of rows under.
I have this and it "kind of" works, but it inserts the
rows in the wrong place. Any more suggestions? Thanks!

Sub addrows()
Dim intCol As Integer
Dim intRow As Integer
For intRow = 3 To 1000
intCol = 11
If Worksheets("Master Schedule").Cells(intRow,
intCol).Value < "" Then
Rowinsert = Value
ActiveCell.Offset(1, 0).EntireRow.Insert
intRow = intRow + 1


-----Original Message-----
Assume the cell with xyz is selected

x = 3
ActiveCell.offset(1,0).Resize(x,1).EntireRow.Inser t

--
Regards,
Tom Ogilvy

Christel wrote in message
...
I have a spreadsheet where I need to insert x number of
rows below the row where the column = "x" For ex.

A B C D
abc 123 xyz 3 I need excel to insert 3 rows beneath
this row.

Any help is appreciated, because I'm not having much luck!

Thanks!



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Inserting # of rows depending on value in Column


Thank you so much! that did the trick!
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
Counting Cells in a column depending on another column but excluding duplicates rwenger Excel Discussion (Misc queries) 0 April 11th 10 01:06 PM
Count/Sum rows of a column depending on criteria from drop-down li YY san.[_2_] Excel Worksheet Functions 4 December 22nd 09 01:43 AM
inserting rows where a formula is inuse for that column Rose Setting up and Configuration of Excel 2 March 7th 08 10:38 PM
Inserting a Date depending on a spereate Cell Value Rob Excel Discussion (Misc queries) 1 November 28th 06 04:08 PM
Merge Rows depending on value of the first column sp123 Excel Worksheet Functions 1 April 20th 06 03:43 AM


All times are GMT +1. The time now is 09:07 PM.

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"