I have spreadsheets that list the dates in column A, ex 12/1/2016 1:45:00 AM. I reformat all the cells in this column so they display Day, Month #, Year. Example Thursday, December 01, 2016
. The Find
function works if I click on the actual find button and search for the values, however I am struggling to code this. I want to delete all the rows that contain "Saturday" and "Sunday". The latest code I have tried is as follows;
Last = Cells(Rows.Count, "D").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "D").Value) = "*Saturday*" Then
Cells(i, "A").EntireRow.Delete
End If
Next i
I have also tried the following code as well;
Set Find = Range("A:A").Find("Saturday", LookIn:=xlValues)
Do Until Find Is Nothing
Find.EntireRow.Delete
Set Find = Range("A:A").FindNext
Loop
将LookAt参数设置为xlPart
Find("Saturday", , , xlPart)
Change
If (Cells(i, "D").Value) = "*Saturday*" Then`
to
If (Cells(i, "D").Text) Like "*Saturday*" Then
Using Text
instead of Value
will access the displayed value, rather than the underlying value (which is a date), and using Like
instead of =
will allow wildcards to work.
Your question is confusing as to which column the dates are in. Some of your code (and your question) suggests they are in column A, but other parts of your code suggest column D. If they are in column A, change the code above to use "A"
instead of "D"
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.