|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub fig168()
Set x = CreateObject("msxml2.domdocument")
Set r = x.createelement("root")
x.appendchild r
For i = 1 To Sheet1.[b65535].End(xlUp).Row
Set aa = x.createelement(Sheet1.Cells(i, "b"))
aa.Text = Sheet1.Cells(i, "b")
Set bb = x.createelement(Sheet1.Cells(i, "b"))
bb.Text = Sheet1.Cells(i, "c")
r.appendchild (aa)
r.appendchild (bb)
Next
y = 2
Do While Sheet2.Cells(y, "d") <> ""
rr = "//" & Sheet2.Cells(y, "d")
Set List = r.selectsinglenode(rr)
If Not List Is Nothing Then
If Val(List.nextsibling.Text) > 0 Then
If Sheet2.Cells(y, "f") <= Val(List.nextsibling.Text) Then
Sheet2.Cells(y, "g") = Sheet2.Cells(y, "f")
kk = Val(List.nextsibling.Text) - Val(Sheet2.Cells(y, "f"))
List.nextsibling.Text = kk
Else
Sheet2.Cells(y, "g") = Val(List.nextsibling.Text)
List.nextsibling.Text = 0
End If
'if sheet2.Cells(
End If
End If
y = y + 1
Loop
End Sub |
|