當前位置:成語大全網 - 新華字典 - WPS,VBA用字典執行為何漏壹個關鍵詞?代碼有誤?這麽修改

WPS,VBA用字典執行為何漏壹個關鍵詞?代碼有誤?這麽修改

Sub?匯總2()

Dim?rng,?dt,?arr,?xm,?brr,?hs,?hk,?r,?t,?j%,?d

Application.ScreenUpdating?=?False

Set?d?=?CreateObject("scripting.dictionary")

With?Worksheets("每天入單")

r?=?.Cells(.Rows.Count,?1).End(xlUp).Row

arr?=?.Range("a1:n"?&?r)

dt?=?.[t1]

Set?rng?=?.Range("a1:n1")

For?j?=?UBound(arr)?To?2?Step?-1

xm?=?arr(j,?2)

If?CDate(dt)?-?CDate(arr(j,?4))?=?0?Then

If?Not?d.exists(xm)?Then

Set?rng?=?Union(rng,?Sheets("每天入單").Range("A"?&?j))

ReDim?brr(1?To?14)

brr(1)?=?arr(j,?2)

brr(2)?=?arr(j,?1)

brr(3)?=?arr(j,?4)

Else

brr?=?d(xm)

End?If

If?arr(j,?5)?=?"折扣"?Then

brr(8)?=?brr(8)?+?arr(j,?13)

brr(5)?=?brr(5)?+?arr(j,?12)

brr(6)?=?brr(6)?+?arr(j,?13)

brr(7)?=?brr(7)?+?arr(j,?14)

d(xm)?=?brr

End?If

End?If

Next

End?With

t?=?d.items

Sheets("當天匯總").Activate

Sheets("當天匯總").UsedRange.Offset(2,?0).Clear

Sheets("當天匯總").Range("a2").Resize(d.Count,?UBound(brr))?=?Application.Transpose(Application.Transpose(t))

For?Each?c?In?Range("a2").Resize(d.Count,?1)

c.Offset(,?0).Resize(1,?7)?=?d(c.Value)

Next

hs?=?[a65536].End(xlUp).Row

For?hk?=?2?To?hs

Cells(hk,?6)?=?Cells(hk,?6)?-?Cells(hk,?8)

Cells(hk,?9)?=?Cells(hk,?5)?-?Cells(hk,?6)?-?Cells(hk,?7)

Next

Range("a1").CurrentRegion.Borders.LineStyle?=?xlContinuous

End?Sub