通过以下函数,我试图在给定的列名中粘贴公式。下面的代码工作正常但是当我的数据上升到65K行时它会抛出:PasteSpecial方法范围类失败错误以及我发现在65K行中当我要在代码下运行时,物理内存使用将为0这是问题,但任何人都可以帮助我逃避或克服这个问题。
谢谢,
Nikunj
这里,代码详细信息:
参数:
Public Function CompareFormat(FormatRng As Range, DataRng As Range, ColArr() As String)
Dim ColIndexArr() As Long
Dim i As Long
Dim DataColRng As Range
Dim FormatColRng As Rangeenter
ColIndexArr = getCompColumnsPosition(DataRng, ColArr())
FormatRng.Rows(1).Copy
DataRng.Rows(1).PasteSpecial xlPasteFormats, xlPasteSpecialOperationNone, False, False
Application.CutCopyMode = False
For i = LBound(ColIndexArr) To UBound(ColIndexArr)
If ColIndexArr(i) > 0 Then
Set DataColRng = Application.Intersect(DataRng.offset(1, 0), _
DataRng.Columns(ColIndexArr(i)))
Set FormatColRng = Application.Intersect(FormatRng.offset(1, 0), _
FormatRng.Columns(ColIndexArr(i)))
FormatColRng.Copy
DataColRng.PasteSpecial xlPasteFormulas
Application.CutCopyMode = False
End If
Next i
End Function