|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub fsclear()
For Each c In Range("A2:A5,C2:C5,E2:E5,A19,A22:A25,C22:C23,E22:E23,G22:G23,I22:I23,K22")
c.Offset(0, 1) = ""
Next
Range("b9:u17").ClearContents
Range("B2") = Date
End Sub
Sub 查询()
If Range("d2") <> "" Then
SR = Range("d2")
ElseIf Range("f2") <> "" Then
SR = Range("f2")
End If
If SR = "" Then Exit Sub
With Sheets("数据库")
Set t = .Range("b:c").Find(SR, lookat:=xlWhole)
If Not t Is Nothing Then
TR = t.Row
Else
MsgBox SR & " Not found "
Exit Sub
End If
For Each c In Range("A2:A5,C2:C5,E2:E5,A19,A22:A25,C22:C23,E22:E23,G22:G23,I22:I23,K22")
Set cc = .Range("a2:gx2").Find(c, lookat:=xlWhole)
c.Offset(0, 1) = .Cells(TR, cc.Column)
Next
For Each c In Range("A9:A17")
Set cc = .Range("a1:gx1").Find(c, lookat:=xlWhole)
For d = 1 To 20
c.Offset(0, d) = .Cells(TR, cc.Column + d - 1)
Next
Next
End With
End Sub
Sub 新建修改()
If Range("d2") <> "" Then '经销商编码
SR = Range("d2")
End If
If SR = "" Then Exit Sub
With Sheets("数据库")
Set t = .Range("b:c").Find(SR, lookat:=xlWhole)
If Not t Is Nothing Then
MsgBox "修改 " & SR
TR = t.Row
Else
MsgBox "新建 " & SR
TR = .[B1048576].End(xlUp).Row + 1
End If
For Each c In Range("A2:A5,C2:C5,E2:E5,A19,A22:A25,C22:C23,E22:E23,G22:G23,I22:I23,K22")
Set cc = .Range("a2:gx2").Find(c, lookat:=xlWhole)
.Cells(TR, cc.Column) = c.Offset(0, 1)
Next
For Each c In Range("A9:A17")
Set cc = .Range("a1:gx1").Find(c, lookat:=xlWhole)
For d = 1 To 20
.Cells(TR, cc.Column + d - 1) = c.Offset(0, d)
Next
Next
End With
End Sub
Sub 删除()
If Range("d2") <> "" Then '经销商编码
SR = Range("d2")
End If
If SR = "" Then Exit Sub
With Sheets("数据库")
Set t = .Range("b:c").Find(SR, lookat:=xlWhole)
If Not t Is Nothing Then
MsgBox "删除 " & SR
TR = t.Row
Else
MsgBox SR & " Not found "
Exit Sub
End If
.Rows(TR).Delete
End With
End Sub
|
|