|
代码有时候会出错,求大神帮忙修改一下,当复制粘贴内容到表格的时候,有时候下标越界,无法运行,麻烦帮忙看看,谢谢- Sub 证书导语()
- Dim Arr, Brr(), crr, rc, cc
- Dim d As Object
-
- Arr = Sheet5.[A3].CurrentRegion
- rc = Sheet1.Cells(Cells.Rows.Count, 1).End(xlUp).Row
- cc = Sheet1.Cells(1, Cells.Columns.Count).End(xlToLeft).Column
- crr = Sheet1.Range(Sheet1.Cells(2, 1), Sheet1.Cells(rc, cc))
- Range("a2:M5000").ClearContents
- r = UBound(Arr)
- Set d = CreateObject("scripting.dictionary")
- For i = 1 To UBound(crr)
- d(crr(i, 1)) = i
- Next
- ReDim Brr(1 To r - 2, 1 To 2 + cc)
- For i = 3 To r
-
- Brr(i - 2, 1) = Arr(i, 1)
- Brr(i - 2, 2) = Arr(i, 4)
- Brr(i - 2, 3) = Arr(i, 6)
- For j = 3 To 2 + cc
- Brr(i - 2, j) = crr(d(Arr(i, 6)), j - 2)
- Next j
- Next i
- Range("a2").Resize(UBound(Brr), 2 + cc) = Brr
- '插入时间
- 'ActiveSheet.Range("j2").Value = Date + Time
- 'ActiveSheet.Range("j2").NumberFormatLocal = "yyyy-mm-dd h:mm:ss"
- Sheets("证书导语").Range("j2").Value = Date + Time
- Sheets("证书导语").Range("j2").NumberFormatLocal = "yyyy-mm-dd h:mm:ss" & " " & "更新"
- Sheets("打印名单").Range("j2").Value = Date + Time
- Sheets("打印名单").Range("j2").NumberFormatLocal = "yyyy-mm-dd h:mm:ss" & " " & "更新"
- End Sub
复制代码
|
|