|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我想修改一下,数据放置时,已有数据的地方不会修改,但修改了好几次,发现水平有限,新数据依然会覆盖已有数据的地方,请哪位老师帮我看下该在哪里修改,谢谢!
主要是以下这段代码中修改:
sub Month_EA
Dim myPW, p
myPW = "esr" '设置密码
p = InputBox("Pls write EA's password", "Kind tips!", Default) '("请输入运行密码", "温馨提示!", Default)
If myPW = p Then
Dim strPath$, Items As FileDialogSelectedItems, dic As Object, vKey
Dim ar, br, cr, dr, i&, j&, k&, k1&, r&, n As Byte, strDate$, t#
strPath = ThisWorkbook.Path & "\"
With Application.FileDialog(1)
With .Filters
.Clear
.Add "DAT file(dat)", "*.dat"
End With
.AllowMultiSelect = True
.InitialFileName = strPath
If .Show Then Set Items = .SelectedItems Else Exit Sub
End With
DoApp False
t = Timer
Set dic = CreateObject("Scripting.Dictionary")
ReDim ar(1 To 10 ^ 5, 1 To 6)
dr = Array(0, 5, 7, 9, 11, 13)
For i = 1 To Items.Count
n = FreeFile
Open Items(i) For Input As #n
br = Split(StrConv(InputB(LOF(n), #n), vbUnicode), vbLf)
Close #n
For j = 0 To UBound(br)
If br(j) <> "" Then
cr = Split(br(j), ",")
r = r + 1
For k = 0 To UBound(dr)
ar(r, k + 1) = cr(dr(k))
Next k
End If
Next j
Next i
For i = 1 To r
dic(ar(i, 1)) = dic(ar(i, 1)) & " " & i
Next i
For Each vKey In dic.keys
cr = Split(dic(vKey))
ReDim br(1 To UBound(cr), 1 To UBound(ar, 2) - 1)
For i = 1 To UBound(cr)
For j = 1 To UBound(ar, 2) - 1
br(i, j) = ar(cr(i), j + 1)
Next j
Next i
dic(vKey) = br
Next
For i = 1 To Sheets.Count
If Sheets(i).Name <> "SPC_MC1" Then
'Sheets(i).Range("C56:CP60").ClearContents
With Sheets(i)
ar = .Range("C49:NC49").Value
br = .Range("C56:NC60").Value
For j = 1 To UBound(ar, 2)
strDate = Format(ar(1, j), "dd/mm/yyyy")
If dic.exists(strDate) Then
n = IIf(UBound(dic(strDate)) > 4, 5, UBound(dic(strDate)))
For k = 1 To n
br(k, j) = dic(strDate)(k, i)
Next k
End If
Next
.Range("C56:NC60").Value = br
'
' .Range("C106:NC110").Value = br
End With
End If
Next i
DoApp
Else
MsgBox "Wrong password, please re-enter!" '"密码错误,请重新输入!", , "温馨提示!
End If
end sub
|
|