试试:
Sub test() '按钮 1
On Error Resume Next
tmp = "找不到需要的供应商"
GYS = InputBox("请输入: 供应商名称")
If GYS = "" Then Exit Sub
[F3:g3].ClearContents '清空原先结果(根据需要修改)可避免查此
Set p = Cells.Find(What:=GYS, LookIn:=xlValues, LookAt:=xlWhole)
If p Is Nothing Then MsgBox tmp: Exit Sub
Rw = p.Row
Col = p.Column
n = Cells(65536, Col).End(xlUp).Row
For i = Rw To n
If Cells(i, Col) = GYS And Cells(i, Col + 1) - x > 0 Then x = Cells(i, Col + 1)
Next
If x = 0 Then MsgBox tmp: Exit Sub
t = Format(x, "yyyy-m-d")
MsgBox "供应商:" & GYS & " // 最后送样日期:" & t & Space(10), 64, " Lwu.提示:"
[F3] = GYS: [g3] = t '写入单元格(根据需要修改)
End Sub
- 相关评论
- 我要评论
-