#1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Code

Hi:

I have 3 col:

1 1 OK
2 2 OK
3 4 NO

I would like please, a code that searches for "no" and
when is found highlight the row and insert another row
above??

Any help is appreciated.

Thsnk,

Dan



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Code

Hi
try the following macro. It tests column C and inserts a row if
the value 'No' appears
Sub insert_rows()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.count, "C").End(xlUp).row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index+1, "C").Value ="No" Then
Cells(row_index + 1, "C").EntireRow.Insert (xlShiftDown)
End If
Next
End Sub


--
Regards
Frank Kabel
Frankfurt, Germany

"Dan" schrieb im Newsbeitrag
...
Hi:

I have 3 col:

1 1 OK
2 2 OK
3 4 NO

I would like please, a code that searches for "no" and
when is found highlight the row and insert another row
above??

Any help is appreciated.

Thsnk,

Dan




  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Code

Thank you very, very much, both!!!

I will try it!

DAn
-----Original Message-----
Hi
try the following macro. It tests column C and inserts a

row if
the value 'No' appears
Sub insert_rows()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.count, "C").End(xlUp).row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index+1, "C").Value ="No" Then
Cells(row_index + 1, "C").EntireRow.Insert

(xlShiftDown)
End If
Next
End Sub


--
Regards
Frank Kabel
Frankfurt, Germany

"Dan" schrieb im

Newsbeitrag
...
Hi:

I have 3 col:

1 1 OK
2 2 OK
3 4 NO

I would like please, a code that searches for "no" and
when is found highlight the row and insert another row
above??

Any help is appreciated.

Thsnk,

Dan




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code

Sub InsertRowBeforeNo()
Dim rng as Range, i as Long
set rng = cells(rows.count,3).End(xlup)
for i = rng.row to 2 step -1
if Ucase(cells(rng.row,3).Value) = "NO" then
cells(rng.row,3).EntireRow.Insert
end if
Next
End Sub

--
Regards,
Tom Ogilvy


"Dan" wrote in message
...
Hi:

I have 3 col:

1 1 OK
2 2 OK
3 4 NO

I would like please, a code that searches for "no" and
when is found highlight the row and insert another row
above??

Any help is appreciated.

Thsnk,

Dan





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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
option buttons run Click code when value is changed via VBA code neonangel Excel Programming 5 July 27th 04 08:32 AM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


All times are GMT +1. The time now is 03:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"