Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / May 2005

Tip: Looking for answers? Try searching our database.

Delete Row syntax conundrum

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JFH - 24 May 2005 10:26 GMT
I have a button that Users can click to create new rows to specify
'Audiences' for a communication. When they click the button a new Audience
row with a cell with a drop down in appears each time. However when I want to
'Reset' the worksheet I only want there to be one Audience row remaining.

The code I currently have is as follows:

Sub IfStatement2()
Dim myList As Variant
Dim i As Long
myList = Array("Fred", "Sue", "Tim", "Tom")
For i = Range("A65536").End(xlUp).Row To 21 Step -1
If Not IsError(Application.Match(Range("A" & i).Value, myList)) Then
Range("A" & i).EntireRow.Delete
End If
Next i
End Sub

I have specified the items in the myList array accurately, but the 'match'
test seems to be a little loose in its application. Any text in the column
beneath my Audiences (even with no relation to the text specified in the
myList array) also seems to bring up a match and thus its row gets deleted.

Is there a way to force an 'exact match'?

Many thanks all.
Bob Phillips - 24 May 2005 11:07 GMT
I think you just need an exact match

Sub IfStatement2()
Dim myList As Variant
Dim i As Long
   myList = Array("Fred", "Sue", "Tim", "Tom")
   For i = Cells(Rows.Count, "A").End(xlUp).Row To 21 Step -1
       If Not IsError(Application.Match(Range("A" & i).Value, myList, 0))
Then
           Rows(i).EntireRow.Delete
       End If
   Next i
End Sub

Signature

HTH

Bob Phillips

> I have a button that Users can click to create new rows to specify
> 'Audiences' for a communication. When they click the button a new Audience
[quoted text clipped - 22 lines]
>
> Many thanks all.
JFH - 24 May 2005 11:31 GMT
Thanks a lot Bob - this works a treat!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.