LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default VBA code deleting everything not just rows with specified values. Please help.

Hi VBA Professionals.
Please see my code. I am trying to only delete rows in an excel sheet where
the value is equal to each string value provided below. However when I run
this macro it deletes everything. I don't know what I am doing wrong. I won't
lie. I am no programmer. Will you please help me with this?
Thanks, Misty

Sub Macro1()
' Keyboard Shortcut: Ctrl+d
'Sub DelEmptyRow()
Rng = Selection.Rows.Count
ActiveCell.Offset(0, 0).Select
Application.ScreenUpdating = False

For i = 1 To Rng
If ActiveCell.Value = "Outpatient Chronic" Then
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If

If ActiveCell.Value = "Dialysis Treatments" Then
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If

If ActiveCell.Value = "Medications" Then
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If

If ActiveCell.Value = "Ferrlecit*" Then
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If

If ActiveCell.Value = "Zemplar*" Then
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If

If ActiveCell.Value = "Cathflo*" Then
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If

If ActiveCell.Value = "Clarity" Then
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If

Next i
Application.ScreenUpdating = True
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200710/1

 
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
Code for deleting rows? fpd833 Excel Programming 6 September 29th 07 06:52 PM
Deleting rows not containing one of 3 values Byron[_5_] Excel Programming 2 October 30th 05 09:45 PM
Deleting Rows with Same Values ...Patrick[_5_] Excel Programming 0 September 8th 04 09:06 PM
VBA code for Deleting rows by verification hoffman3 Excel Programming 4 June 3rd 04 08:55 PM
Code deleting values -- not as intended Stuart[_5_] Excel Programming 2 May 3rd 04 07:36 PM


All times are GMT +1. The time now is 06:37 PM.

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"