Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
How can I create a macro that would delete two rows. The first row is the one where the cell value in Column A is "L" and the second row is the row above it. So if A15, A20, A23 has the value (and only value) of "L" then delete it and the row above it, which would be A14, A19, A22. Thanks, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, How can I create a macro that would delete two rows. The first row is the one where the cell value in Column A is "L" and the second row is the row above it. So if A15, A20, A23 has the value (and only value) of "L" then delete it and the row above it, which would be A14, A19, A22. Thanks, Ah I wrote something similar earlier today at work. Sub DeleteLRows() Dim cl As Range For Each cl In Selection cl.Select If UCase(ActiveCell.Value) = "L" Then ActiveCell.EntireRow.Delete ActiveCell.Offset(-1, 0).EntireRow.Delete End If Next End Sub it might need a tweak but it should give you something towards what uyou need. it works on cells you select. somethinglikeant -- SLAnt ------------------------------------------------------------------------ SLAnt's Profile: http://www.excelforum.com/member.php...o&userid=34184 View this thread: http://www.excelforum.com/showthread...hreadid=539933 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi SLAnt,
Thanks for the code. I'm also trying to learn to program with VBA so what is cl mean in your code? "SLAnt" wrote: Hi, How can I create a macro that would delete two rows. The first row is the one where the cell value in Column A is "L" and the second row is the row above it. So if A15, A20, A23 has the value (and only value) of "L" then delete it and the row above it, which would be A14, A19, A22. Thanks, Ah I wrote something similar earlier today at work. Sub DeleteLRows() Dim cl As Range For Each cl In Selection cl.Select If UCase(ActiveCell.Value) = "L" Then ActiveCell.EntireRow.Delete ActiveCell.Offset(-1, 0).EntireRow.Delete End If Next End Sub it might need a tweak but it should give you something towards what uyou need. it works on cells you select. somethinglikeant -- SLAnt ------------------------------------------------------------------------ SLAnt's Profile: http://www.excelforum.com/member.php...o&userid=34184 View this thread: http://www.excelforum.com/showthread...hreadid=539933 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
C1 appears to be a variable, like "x" except the programmer chose to
call it "C1." The programmer specified that it is a special kind of variable, that is that it is a variable that describes a Range. Ivano wrote: Hi SLAnt, Thanks for the code. I'm also trying to learn to program with VBA so what is cl mean in your code? "SLAnt" wrote: Hi, How can I create a macro that would delete two rows. The first row is the one where the cell value in Column A is "L" and the second row is the row above it. So if A15, A20, A23 has the value (and only value) of "L" then delete it and the row above it, which would be A14, A19, A22. Thanks, Ah I wrote something similar earlier today at work. Sub DeleteLRows() Dim cl As Range For Each cl In Selection cl.Select If UCase(ActiveCell.Value) = "L" Then ActiveCell.EntireRow.Delete ActiveCell.Offset(-1, 0).EntireRow.Delete End If Next End Sub it might need a tweak but it should give you something towards what uyou need. it works on cells you select. somethinglikeant -- SLAnt ------------------------------------------------------------------------ SLAnt's Profile: http://www.excelforum.com/member.php...o&userid=34184 View this thread: http://www.excelforum.com/showthread...hreadid=539933 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No tested it, just wrote it, may need a slight change
For x = 5000 to 1 step -1 If sheet1.cells(x, 1).value = "L" then rows(x).delete rows(x -1).delete end if next x -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200605/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy rows based on cell content | Excel Discussion (Misc queries) | |||
Need to select/report all rows based on content | Excel Programming | |||
Delete Rows Based On Content | Excel Programming | |||
Delete Rows Based On Content | Excel Programming |