Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 143
Default inserting a row based on a condition.

i need a macro to do the following.

if value in cell is =x then insert a row above.

Possible?


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 296
Default inserting a row based on a condition.

On Fri, 18 Aug 2006 05:25:15 -0600, "Gary"
wrote:

i need a macro to do the following.

if value in cell is =x then insert a row above.

Possible?



Yes, but you need to give some more details as to how this is intended
to operate.

i.e. Are you referring to just a single cell such that when its value
changes to be greater than x, the row is inserted, or are you trying
to loop down a column of cells and wanting to insert several rows if
the condition is met?

If the former, do you want this to kick in once only, or every time x
is changed so that a row might be inserted several times if the
condition is met

Rgds


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 143
Default inserting a row based on a condition.

Sorry for not being clear Richard. What I want is whenever the in any cell
in column A is =x, the macro should insert a row right above that row.

For example - if i enter x in A14, the macro should insert a row above. now
A14 will automatically become A15.

thanks in advance.

"Richard Buttrey" wrote in
message ...
On Fri, 18 Aug 2006 05:25:15 -0600, "Gary"
wrote:

i need a macro to do the following.

if value in cell is =x then insert a row above.

Possible?



Yes, but you need to give some more details as to how this is intended
to operate.

i.e. Are you referring to just a single cell such that when its value
changes to be greater than x, the row is inserted, or are you trying
to loop down a column of cells and wanting to insert several rows if
the condition is met?

If the former, do you want this to kick in once only, or every time x
is changed so that a row might be inserted several times if the
condition is met

Rgds


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 296
Default inserting a row based on a condition.



Put the following in the worksheet_change event procedure



Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Target = "x" Then
Target.EntireRow.Insert
End If
End If
End Sub


I wasn't quite sure if you really meant = x or just x

The above will insert a row only if you enter an 'x' in column A.
If you really do mean = x, i.e a row is inserted if you enter x, y or
z then just change the ="x" to ="x"

HTH




On Fri, 18 Aug 2006 06:00:51 -0600, "Gary"
wrote:

Sorry for not being clear Richard. What I want is whenever the in any cell
in column A is =x, the macro should insert a row right above that row.

For example - if i enter x in A14, the macro should insert a row above. now
A14 will automatically become A15.

thanks in advance.

"Richard Buttrey" wrote in
message ...
On Fri, 18 Aug 2006 05:25:15 -0600, "Gary"
wrote:

i need a macro to do the following.

if value in cell is =x then insert a row above.

Possible?



Yes, but you need to give some more details as to how this is intended
to operate.

i.e. Are you referring to just a single cell such that when its value
changes to be greater than x, the row is inserted, or are you trying
to loop down a column of cells and wanting to insert several rows if
the condition is met?

If the former, do you want this to kick in once only, or every time x
is changed so that a row might be inserted several times if the
condition is met

Rgds


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________



__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
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
Color Change in chart based of condition KRT Charts and Charting in Excel 1 July 1st 05 12:51 PM
Adding cells based on condition Ted Metro Excel Worksheet Functions 1 June 22nd 05 09:15 PM
Counting Across Multiple Ranges, Based on Condition Stacy Excel Worksheet Functions 2 June 22nd 05 08:35 PM
How do I hide a column based on a condition (option not available. jgentillet Excel Worksheet Functions 0 January 24th 05 02:53 PM
make a cell empty based on condition mpierre Charts and Charting in Excel 2 December 29th 04 01:01 PM


All times are GMT +1. The time now is 10:28 AM.

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"