Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Code and thanks for/to Tom and Frank

Hello again:

Thanks again guys but is not working:

So I have a big file; here are just few rows...

1 1 OK
2 2 OK
3 4 NO
2 2 OK
5 6 NO
******************

The code taht I would need is to search for no and when is
found to insert a row above

Thanks again and I am still testing those codes you gave
me but does not produce any result?

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

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,

Dan



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code and thanks for/to Tom and Frank

Mine should actually be:

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(i, 3).Value) = "NO" Then
Cells(i, 3).EntireRow.Insert
End If
Next
End Sub

That worked fine for me. Assumes NO and YES are in the third column.

Frank's doesn't work because NO < No.

--
Regards,
Tom Ogilvy

"Dan" wrote in message
...
Hello again:

Thanks again guys but is not working:

So I have a big file; here are just few rows...

1 1 OK
2 2 OK
3 4 NO
2 2 OK
5 6 NO
******************

The code taht I would need is to search for no and when is
found to insert a row above

Thanks again and I am still testing those codes you gave
me but does not produce any result?

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

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,

Dan





  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Code and thanks for/to Tom and Frank

Hi again:

Frank, yours is working now, but my mistake, I would need
inserted not the whole row; just for the 3 columns: sort
of shift cells down; there are other columns after c and I
have autofilter; something like belowlike below...
1 1 OK a
2 2 OK a
b
3 4 NO c
57 7 NO a


Thank you very much,

Dan

PS Tom your did not have a result...

-----Original Message-----
Mine should actually be:

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(i, 3).Value) = "NO" Then
Cells(i, 3).EntireRow.Insert
End If
Next
End Sub

That worked fine for me. Assumes NO and YES are in the

third column.

Frank's doesn't work because NO < No.

--
Regards,
Tom Ogilvy

"Dan" wrote in

message
...
Hello again:

Thanks again guys but is not working:

So I have a big file; here are just few rows...

1 1 OK
2 2 OK
3 4 NO
2 2 OK
5 6 NO
******************

The code taht I would need is to search for no and when

is
found to insert a row above

Thanks again and I am still testing those codes you gave
me but does not produce any result?

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

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,

Dan





.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code and thanks for/to Tom and Frank

PS: Dan, it worked fine for me and the technique is identical to Frank's,
so Don't think the problem is my code - at least not with the information
you presented.

Please try to stay in the thread and not start new threads without context.

--
Regards,
Tom Ogilvy

"Dan" wrote in message
...
Hi again:

Frank, yours is working now, but my mistake, I would need
inserted not the whole row; just for the 3 columns: sort
of shift cells down; there are other columns after c and I
have autofilter; something like belowlike below...
1 1 OK a
2 2 OK a
b
3 4 NO c
57 7 NO a


Thank you very much,

Dan

PS Tom your did not have a result...

-----Original Message-----
Mine should actually be:

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(i, 3).Value) = "NO" Then
Cells(i, 3).EntireRow.Insert
End If
Next
End Sub

That worked fine for me. Assumes NO and YES are in the

third column.

Frank's doesn't work because NO < No.

--
Regards,
Tom Ogilvy

"Dan" wrote in

message
...
Hello again:

Thanks again guys but is not working:

So I have a big file; here are just few rows...

1 1 OK
2 2 OK
3 4 NO
2 2 OK
5 6 NO
******************

The code taht I would need is to search for no and when

is
found to insert a row above

Thanks again and I am still testing those codes you gave
me but does not produce any result?

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

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,

Dan





.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Code and thanks for/to Tom and Frank

Hi
what does happen exactly?

--
Regards
Frank Kabel
Frankfurt, Germany

"Dan" schrieb im Newsbeitrag
...
Hello again:

Thanks again guys but is not working:

So I have a big file; here are just few rows...

1 1 OK
2 2 OK
3 4 NO
2 2 OK
5 6 NO
******************

The code taht I would need is to search for no and when is
found to insert a row above

Thanks again and I am still testing those codes you gave
me but does not produce any result?

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

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,

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
Frank Kobel Adam Excel Discussion (Misc queries) 3 December 29th 04 02:55 PM
Thank you so much, Frank Kabel and ~X! Kim-Anh Tran[_27_] Excel Programming 1 May 18th 04 11:17 PM
Message for Frank K Rich B[_3_] Excel Programming 4 May 16th 04 05:48 PM
Frank Kabel nrage21[_49_] Excel Programming 6 April 22nd 04 02:36 PM
Frank - Thanks Tim Excel Programming 0 February 12th 04 06:52 PM


All times are GMT +1. The time now is 04:19 AM.

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"