我的代码有轻微问题。我有从数据库提取数据并将其放入表中的代码。示例:
我希望L列中的单元格突出显示(例如红色),前提是数据重复了3个移位。或者,如果无法做到这一点,至少可以通过某种方式轻松地看到何时重复数据。
这个想法是我提取超出特定范围的数据。
SQL代码:
sql = "SELECT ID, (SELECT Number FROM WindingStands WHERE ID = TexMeasurements.WindingStandID) as Place, SpindleNumber, " _
& "(SELECT Number FROM Assortments WHERE ID = TexMeasurements.AssortmentID) as Sifrs, " _
& "(SELECT Name FROM Assortments WHERE ID = TexMeasurements.AssortmentID) as Sort, CreationTime, TexPV, TexSP " _
& " FROM TexMeasurements " _
& " WHERE CreationTime > " & fromdate & " AND CreationTime <= " & ToDate & " " _
& " AND (TexLimit <= -3 OR TexLimit >= 3) ORDER BY Place, SpindleNumber, CreationTime"
我使用代码来查看每天的数据,如下所示:
Sub LastShift()
If (Sheets(1).Cells(1, 1).Value - Sheets(1).Cells(1, 2).Value) > 0.75 Then
Sheets(1).Cells(2, 6).Value = Sheets(1).Cells(1, 2).Value + 0.75
Sheets(1).Cells(2, 3).Value = Sheets(1).Cells(2, 6).Value - 0.5
End If
If (Sheets(1).Cells(1, 1).Value - Sheets(1).Cells(1, 2).Value) < 0.25 Then
Sheets(1).Cells(2, 6).Value = Sheets(1).Cells(1, 2).Value - 0.25
Sheets(1).Cells(2, 3).Value = Sheets(1).Cells(2, 6).Value - 0.5
End If
If (Sheets(1).Cells(1, 1).Value - Sheets(1).Cells(1, 2).Value) > 0.25 And (Sheets(1).Cells(1, 1).Value - Sheets(1).Cells(1, 2).Value) < 0.75 Then
Sheets(1).Cells(2, 6).Value = Sheets(1).Cells(1, 2).Value + 0.25
Sheets(1).Cells(2, 3).Value = Sheets(1).Cells(2, 6).Value - 0.5
End If
Call ExtractData
Sub ThisShift()
If (Sheets(1).Cells(1, 1).Value - Sheets(1).Cells(1, 2).Value) > 0.25 And (Sheets(1).Cells(1, 1).Value - Sheets(1).Cells(1, 2).Value) < 0.75 Then
Sheets(1).Cells(2, 6).Value = Sheets(1).Cells(1, 2).Value + 0.75
Sheets(1).Cells(2, 3).Value = Sheets(1).Cells(1, 2).Value + 0.25
End If
If (Sheets(1).Cells(1, 1).Value - Sheets(1).Cells(1, 2).Value) < 0.25 Then
Sheets(1).Cells(2, 6).Value = Sheets(1).Cells(1, 2).Value + 0.25
Sheets(1).Cells(2, 3).Value = Sheets(1).Cells(2, 6).Value - 0.5
End If
If (Sheets(1).Cells(1, 1).Value - Sheets(1).Cells(1, 2).Value) > 0.75 Then
Sheets(1).Cells(2, 6).Value = Sheets(1).Cells(1, 2).Value + 1.25
Sheets(1).Cells(2, 3).Value = Sheets(1).Cells(2, 6).Value - 0.5
End If
Call ExtractData
答案 0 :(得分:0)
在K
列中,您可以输入一个公式,如下所示:
=IF(AND(MATCH(J4;J3;0);MATCH(J4;J2;0));1;0)
如果单元格值J3和J4相等,而J2和J4相等,则看到1,否则看到#N/A
(而不是零,对不起)。显然,您还可以使用Exact()
工作表功能。