Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete Rows based on criteria in Column A (not working)


I am trying to put additional functionality in this code to delete row
with "3/25/2005" or "12/31/2004" in column A.

This doesn't work, yet it doesn't give any errors.
When i check my sheet, it deletes duplicate rows but not the rows wit
"3/25/2005" or "12/31/2004".
Please can anyone take a look? Thanks


Code
-------------------

'DELETE DUPLICATE ROWS AND DELETE ROWS WITH CRITERIA
Dim i As Long
Dim cursheet As Worksheet
Set cursheet = Worksheets("DataTable")
For i = cursheet.Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If WorksheetFunction.CountIf(cursheet.Range(cursheet. Cells(2, 1), cursheet.Cells(i, 1)), cursheet.Cells(i, 1)) 1 Or _
Cells(i, "A").Value = "3/25/2005" Or _
Cells(i, "A").Value = "12/31/2004" Then
cursheet.Cells(i, 1).EntireRow.Delete
End If
Next i

-------------------

--
Mslad
-----------------------------------------------------------------------
Mslady's Profile: http://www.excelforum.com/member.php...fo&userid=2777
View this thread: http://www.excelforum.com/showthread.php?threadid=48024

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Delete Rows based on criteria in Column A (not working)

I wonder if you don't need to put the dates in between # signs, ie #3/25/2005#

"Mslady" wrote:


I am trying to put additional functionality in this code to delete rows
with "3/25/2005" or "12/31/2004" in column A.

This doesn't work, yet it doesn't give any errors.
When i check my sheet, it deletes duplicate rows but not the rows with
"3/25/2005" or "12/31/2004".
Please can anyone take a look? Thanks


Code:
--------------------

'DELETE DUPLICATE ROWS AND DELETE ROWS WITH CRITERIA
Dim i As Long
Dim cursheet As Worksheet
Set cursheet = Worksheets("DataTable")
For i = cursheet.Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If WorksheetFunction.CountIf(cursheet.Range(cursheet. Cells(2, 1), cursheet.Cells(i, 1)), cursheet.Cells(i, 1)) 1 Or _
Cells(i, "A").Value = "3/25/2005" Or _
Cells(i, "A").Value = "12/31/2004" Then
cursheet.Cells(i, 1).EntireRow.Delete
End If
Next i

--------------------


--
Mslady
------------------------------------------------------------------------
Mslady's Profile: http://www.excelforum.com/member.php...o&userid=27776
View this thread: http://www.excelforum.com/showthread...hreadid=480242


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete Rows based on criteria in Column A (not working)


Hi Kleev,
I tried again, still no luck.

It works when i put it in my module, but not when i put it in my sheet
Any ideas

--
Mslad
-----------------------------------------------------------------------
Mslady's Profile: http://www.excelforum.com/member.php...fo&userid=2777
View this thread: http://www.excelforum.com/showthread.php?threadid=48024

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
Delete Rows based on criteria in excel Novaglory Excel Discussion (Misc queries) 5 July 10th 07 08:29 PM
Code help, delete rows based on column criteria Stout Excel Discussion (Misc queries) 2 March 20th 07 01:17 PM
How can I delete rows programmatically based on certain criteria? nt_artagnian[_2_] Excel Worksheet Functions 1 March 7th 07 05:48 PM
Delete rows based on criteria Chris_t_2k5 Excel Discussion (Misc queries) 2 April 11th 06 01:52 PM
Delete rows based on certain criteria Coal Miner Excel Discussion (Misc queries) 2 March 3rd 06 05:56 PM


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