我使用以下代码尝试查找一个月的所有实例+"销售" +年,然后删除该行。但是,我得到了一个不匹配的错误。我不认为我的.Find函数可以采用列表的参数。我尝试使用循环WITHIN循环遍历列表中的所有变量,但仍然出现不匹配错误。关于如何解决这个问题的任何想法?感谢:
<?php
$sql = "
SELECT round(avg(`rate`),2) AS `average_rate`, count(`rate`) AS `num_of_rating`
FROM tbl_rating
WHERE hotel_id = '$id' ";
$query = mysqli_query($con,$sql);
$rating = mysqli_fetch_assoc($query);
?>
<div>
<h4 style="color: #1478FF; font-size:30px; font-family: " > <?php echo $rating['average_rate']; ?> Average rating </h4>
<?php
$limit = floor($rating['average_rate']);
$remainder = $rating['average_rate'] % 1.0;
for( $i = 0; $i<$limit; $i++ ) {
echo ("<img src=\"\\images\\fullstar.jpg\" />");
}
if ($remainder >= 0.5) echo ("<img src=\"\\images\\halfstar.jpg\" />");
?>
</div>
如果您能找到更好的方式以yyyy格式查找任何年份而不是手动列出它们,那么
奖励。我确定我可以使用日期功能来实现这一目标,但我有足够的时间来获取这个仅仅是一个简单的列表...
答案 0 :(得分:3)
这样的事情对你有用:
Sub tgr()
Dim ws As Worksheet
Dim rSearch As Range
Dim rFound As Range
Dim rDel As Range
Dim aYears() As Variant
Dim aMonths() As Variant
Dim vYear As Variant
Dim vMonth As Variant
Dim sTemp As String
Dim sFirst As String
Set ws = ActiveWorkbook.ActiveSheet
Set rSearch = ws.Columns("C").EntireColumn
aMonths = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
aYears = Array(2014, 2015, 2016, 2017, 2018, 2019, 2020)
For Each vYear In aYears
For Each vMonth In aMonths
sTemp = vMonth & " Sales " & vYear
Set rFound = Nothing
Set rFound = rSearch.Find(sTemp, rSearch.Cells(rSearch.Cells.Count), xlValues, xlPart, , xlNext, False)
If Not rFound Is Nothing Then
sFirst = rFound.Address
If rDel Is Nothing Then Set rDel = rFound Else Set rDel = Union(rDel, rFound)
Do
Set rDel = Union(rDel, rFound)
Set rFound = rSearch.FindNext(rFound)
Loop While rFound.Address <> sFirst
End If
Next vMonth
Next vYear
If Not rDel Is Nothing Then rDel.EntireRow.Delete
End Sub
答案 1 :(得分:2)
批量自动过滤操作通常比循环单个查找操作快得多。
#include <immintrin.h>
#include <stdint.h>
#include <math.h>
.
.
_mm256_set_m128d( _mm256_extractf128_pd(t2, 0) + _mm256_extractf128_pd(t2, 1),
_mm256_extractf128_pd(t1, 0) + _mm256_extractf128_pd(t1, 1));