Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pat Pat is offline
external usenet poster
 
Posts: 122
Default delete row programmatically

Is it possible to delete a row on a sheet programmatically? If say data in
A4, A7, A37 contained the word "delete" could it be possible for code to
find the word "delete" colA and then proceed to delete the entire row?

Any thoughts about whether this is possible?
Pat


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

Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, 1).Value = "delete" then
rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub

also have a look at:
http://www.xldynamic.com/source/xld.Deleting.html

--
Regards
Frank Kabel
Frankfurt, Germany


Pat wrote:
Is it possible to delete a row on a sheet programmatically? If say
data in A4, A7, A37 contained the word "delete" could it be possible
for code to find the word "delete" colA and then proceed to delete
the entire row?

Any thoughts about whether this is possible?
Pat

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default delete row programmatically

Sub TryThis()
Dim X As Long
Dim Y As Long
Y = Range("A65536").End(xlUp).Row
'y= find the last non empty cell in column A
For X = Y To 1 Step -1
'Lcase gets the lower case of the word
If lcase(Cells(X, 1).Value) = "delete" Then
Rows(X).Delete
End If
Next

--
Message posted from http://www.ExcelForum.com

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
How can I delete rows programmatically based on certain criteria? nt_artagnian[_2_] New Users to Excel 2 March 8th 07 03:56 AM
How can I delete rows programmatically based on certain criteria? nt_artagnian[_2_] Excel Worksheet Functions 1 March 7th 07 05:48 PM
How to delete lines programmatically if a condition is met? nt_artagnian[_2_] Excel Discussion (Misc queries) 1 March 7th 07 05:39 PM
Delete modules programmatically and save Brijesh Shah Excel Programming 3 December 24th 03 08:14 PM
Excel VBA Programmatically delete a form? Anthony Keefe Excel Programming 0 August 30th 03 10:03 PM


All times are GMT +1. The time now is 05:44 PM.

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

About Us

"It's about Microsoft Excel"