Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default delet rows based on cel content

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default delet rows based on cel content


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default delet rows based on cel content

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default delet rows based on cel content

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default delet rows based on cel content

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
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
Copy rows based on cell content billinr Excel Discussion (Misc queries) 2 February 14th 07 08:17 PM
Need to select/report all rows based on content Kristin Excel Programming 6 January 20th 06 05:57 PM
Delete Rows Based On Content halem2[_39_] Excel Programming 0 October 12th 04 03:27 PM
Delete Rows Based On Content halem2[_38_] Excel Programming 1 October 12th 04 03:16 PM


All times are GMT +1. The time now is 03:53 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"