给出一个简单的表,如下所示:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
'Do logic for this first range
Dim rng As Range
rng = Range([H2], Cells(Rows.Count, "H").End(xlUp)))
If Not Intersect(rng, Target) Is Nothing Then
rng.Offset(, 1).FormulaR1C1 = "=IF(RC[-1]<>"""",R1C[6] & ""-"" &" & "TEXT(COUNTA(R2C[-1]:RC[-1]),""0000"") & ""-"" & R1C[7],"""")"
End If
'now do logic for the second range (move_blanks_to_bottom)
If Target.CountLarge = 1 And Target.Column = 9 Then
Range("A1", Range("A" & Rows.Count).End(xlUp)).Resize(, 11).Sort key1:=Range("I1"), order1:=xlAscending, Header:=xlYes
End If
Application.EnableEvents = True
End Sub
我需要返回不存在记录(在这种情况下为4)或var2等于5(在这种情况下为6)的最小值(var1,为2的倍数)。我需要将其作为单个查询来执行,但不幸的是,我是MySQL函数的新手。
我试图创建一个像这样的函数:
var1 | var2
0 | 3
2 | 4
6 | 5
但是它似乎不起作用。 谢谢。