C列为价格列,数组公式(花括号是由ctrl+shift+enter结束输入所生成的)
b、=sumproduct((d1:d100="白炽灯")*(b1:b100>=80))-sumproduct((d1:d100="白炽灯")*(b1:b100>100))
'//引用Microsoft Data Oblject ActiveX 2.5'//模块里面写函数,例如我写查询远程SQL数据库
'1.先初始化
For I = 3 To 600 Step 1
Sheet3.Cells(I, 1) = ""
Sheet3.Cells(I, 2) = ""
Sheet3.Cells(I, 3) = ""
Sheet3.Cells(I, 4) = ""
Sheet3.Cells(I, 5) = ""
Sheet3.Cells(I, 6) = ""
Sheet3.Cells(I, 7) = ""
Sheet3.Cells(I, 8) = ""
Sheet3.Cells(I, 9) = ""
Sheet3.Cells(I, 10) = ""
Sheet3.Cells(I, 11) = ""
Sheet3.Cells(I, 12) = ""
Sheet3.Cells(I, 13) = ""
Next I
'//再连接数据库
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset
'//当然也可以连接自身表格,语句网上大把的
cnn.ConnectionString = "Driver={SQL Server}Server=192.168.1.200UID=saPWD=5332852DataBase=SmartSchedule"
cnn.Open
'//在这里按条件筛选
rs.Open "Select * from 尾欠信息 where 核对时间='" + Str(Sheet3.Cells(1, 8)) + "' order by 批次", cnn
'//从除列名外位置,填充数据
Dim n As Integer
n = 2
Do While Not rs.EOF
Sheet3.Cells(n + 1, 1) = n - 1
Sheet3.Cells(n + 1, 2) = rs.Fields("批次")
Sheet3.Cells(n + 1, 3) = rs.Fields("下单数量")
Sheet3.Cells(n + 1, 4) = rs.Fields("特征")
Sheet3.Cells(n + 1, 5) = rs.Fields("下单日期")
Sheet3.Cells(n + 1, 6) = rs.Fields("需求日期")
Sheet3.Cells(n + 1, 7) = rs.Fields("尾欠")
Sheet3.Cells(n + 1, 8) = rs.Fields("备注")
Sheet3.Cells(n + 1, 9) = rs.Fields("核对结果")
Sheet3.Cells(n + 1, 10) = rs.Fields("异常说明")
Sheet3.Cells(n + 1, 11) = rs.Fields("异常时间")
Sheet3.Cells(n + 1, 12) = rs.Fields("相关解决人")
Sheet3.Cells(n + 1, 13) = rs.Fields("核对时间")
rs.MoveNext
n = n + 1
Loop
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)