Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 173
Default Add rows depend on the number in a cell

Dear Expert,
In A1, it has a number 3.
In A2, it has a number 5.
In A3, it has a number 4.
I want to run a marco that add 2 rows if A1 contains a number of 3.
It adds 4 rows if A2 contains a number of 5.
It adds 3 rows if A3 contains a number of 4.
After running, Number 3 will move to A3 (add 2 rows already).
Number 5 will move to A8 (add 4 rows already)
Number 4 will move to A12 (add 3 rows already)
Is it too difficult ?
Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Add rows depend on the number in a cell

Hi,

Right click your sheet tab, view code and paste this in and run it.

Sub addrows()
For x = 3 To 1 Step -1
For y = 1 To Cells(x, 1).Value - 1
Rows(x).EntireRow.Insert
Next
Next
End Sub

Mike

"Elton Law" wrote:

Dear Expert,
In A1, it has a number 3.
In A2, it has a number 5.
In A3, it has a number 4.
I want to run a marco that add 2 rows if A1 contains a number of 3.
It adds 4 rows if A2 contains a number of 5.
It adds 3 rows if A3 contains a number of 4.
After running, Number 3 will move to A3 (add 2 rows already).
Number 5 will move to A8 (add 4 rows already)
Number 4 will move to A12 (add 3 rows already)
Is it too difficult ?
Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Add rows depend on the number in a cell

try this
Sub insertvarrows()
mc = 1
For i = Cells(Rows.Count, mc).End(xlUp).Row To 1 Step -1
Rows(i).Resize(Cells(i, mc)).Insert
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Elton Law" wrote in message
...
Dear Expert,
In A1, it has a number 3.
In A2, it has a number 5.
In A3, it has a number 4.
I want to run a marco that add 2 rows if A1 contains a number of 3.
It adds 4 rows if A2 contains a number of 5.
It adds 3 rows if A3 contains a number of 4.
After running, Number 3 will move to A3 (add 2 rows already).
Number 5 will move to A8 (add 4 rows already)
Number 4 will move to A12 (add 3 rows already)
Is it too difficult ?
Thanks in advance.


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
Dropdown depend on product with default value noord453 Excel Discussion (Misc queries) 0 October 14th 08 11:14 AM
how to calculate depend on drop-down list value? tracy Excel Discussion (Misc queries) 1 December 3rd 07 01:15 AM
Please help, My job may depend on it!!! Kev Excel Discussion (Misc queries) 9 May 3rd 07 05:02 PM
Auto run macro depend on cell value Khaled Excel Worksheet Functions 2 April 25th 07 10:52 PM
How to show data from other sheet depend on value?? Malka Excel Worksheet Functions 3 February 27th 06 08:51 AM


All times are GMT +1. The time now is 07:48 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"