Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have the following code which compiles and runs; however, it isn' deleting rows as it should be. Basically I want the macro to chec each row of Column O and if that value is < 3301, delete the entire ro and shift the cels up. The code is: For i = 2 To 2000 If ActiveWorkbook.Worksheets(1).Cells(i, "O").Value < "" Then If ActiveWorkbook.Worksheets(1).Cells(i, "O").Value < 330 Then Rows(i).Delete Shift:=xlUp End If End If Next Just to make sure the loop is functioning properly I changed the delet line to With Row(i).Interior .ColorIndex = 6 .Pattern = xlSolid End With This made every row with the value less than 3301 highlighted yellow s the loop functions fine. Just the deleteing part of it isn't.. -- Goobie ----------------------------------------------------------------------- Goobies's Profile: http://www.excelforum.com/member.php...fo&userid=3076 View this thread: http://www.excelforum.com/showthread.php?threadid=50756 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() You need to delete from bottom up ...... For i = 2000 To 2 Step -1 HTH "Goobies" wrote: I have the following code which compiles and runs; however, it isn't deleting rows as it should be. Basically I want the macro to check each row of Column O and if that value is < 3301, delete the entire row and shift the cels up. The code is: For i = 2 To 2000 If ActiveWorkbook.Worksheets(1).Cells(i, "O").Value < "" Then If ActiveWorkbook.Worksheets(1).Cells(i, "O").Value < 3301 Then Rows(i).Delete Shift:=xlUp End If End If Next Just to make sure the loop is functioning properly I changed the delete line to With Row(i).Interior .ColorIndex = 6 .Pattern = xlSolid End With This made every row with the value less than 3301 highlighted yellow so the loop functions fine. Just the deleteing part of it isn't... -- Goobies ------------------------------------------------------------------------ Goobies's Profile: http://www.excelforum.com/member.php...o&userid=30768 View this thread: http://www.excelforum.com/showthread...hreadid=507566 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Toppers you're brilliant! :) Thanks for the help! Toppers Wrote: You need to delete from bottom up ...... For i = 2000 To 2 Step -1 HTH "Goobies" wrote: I have the following code which compiles and runs; however, it isn't deleting rows as it should be. Basically I want the macro to check each row of Column O and if that value is < 3301, delete the entire row and shift the cels up. The code is: For i = 2 To 2000 If ActiveWorkbook.Worksheets(1).Cells(i, "O").Value < "" Then If ActiveWorkbook.Worksheets(1).Cells(i, "O").Value < 3301 Then Rows(i).Delete Shift:=xlUp End If End If Next Just to make sure the loop is functioning properly I changed the delete line to With Row(i).Interior .ColorIndex = 6 .Pattern = xlSolid End With This made every row with the value less than 3301 highlighted yellow so the loop functions fine. Just the deleteing part of it isn't... -- Goobies ------------------------------------------------------------------------ Goobies's Profile: http://www.excelforum.com/member.php...o&userid=30768 View this thread: http://www.excelforum.com/showthread...hreadid=507566 -- Goobies ------------------------------------------------------------------------ Goobies's Profile: http://www.excelforum.com/member.php...o&userid=30768 View this thread: http://www.excelforum.com/showthread...hreadid=507566 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete rows using a macro | Excel Discussion (Misc queries) | |||
macro to delete rows | Excel Discussion (Misc queries) | |||
Need a macro to delete rows | Excel Discussion (Misc queries) | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming |