|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub fig168()
Set x = CreateObject("msxml2.domdocument")
Set r = x.createelement("xml")
x.appendchild r
For i = 1 To Sheet1.[a65535].End(xlUp).Row
Set rr = x.createelement("root")
kk = Sheet1.Cells(i, "a")
'kk = Replace("kk", "-", "")
Set aa = x.createelement("name")
aa.Text = kk
Set bb = x.createelement("amt")
bb.Text = Sheet1.Cells(i, "b")
rr.appendchild (aa)
rr.appendchild (bb)
r.appendchild (rr)
Next
y = 2
Do While Sheet4.Cells(y, "d") <> ""
ll = Sheet4.Cells(y, "d")
Set List = r.SelectSingleNode("//name[text()='" & ll & "']")
If Not List Is Nothing Then
'Debug.Print List.LastChild.Text
If Val(List.NextSibling.Text) > 0 Then
If Sheet4.Cells(y, "e") <= Val(List.NextSibling.Text) Then
Sheet4.Cells(y, "f") = Sheet4.Cells(y, "e")
kk = Val(List.NextSibling.Text) - Val(Sheet4.Cells(y, "e"))
List.NextSibling.Text = kk
Else
Sheet4.Cells(y, "f") = Val(List.NextSibling.Text)
Debug.Print List.NextSibling.Text
List.NextSibling.Text = 0
End If
'if sheet4.Cells(
End If
End If
y = y + 1
Loop
End Sub |
|