在 excel 2007 中导致错误。如何在不兼容模式下添加工作簿
事实证明,发生错误是因为我制作的新工作簿 workbook.add 是在与 excel 2003 的兼容模式下制作的,其限制为 65536 行。我尝试粘贴的范围的行数比这更多。如何添加处于兼容模式的工作簿?
For c = 1 To Round(z / x + 0.5)
Rows("9:" & x).Select
Selection.Copy
Workbooks.Add
Range("A9").Select
ActiveSheet.Paste
'Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.ActivateNext
Selection.Delete
Rows("1:8").Copy
ActiveWindow.ActivatePrevious
Range("A1").Select
ActiveSheet.Paste
'Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E3") = c
ActiveWorkbook.SaveAs Filename:=FileLocation2 & "\" & g & "-" & c _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ThisWorkbook.Save
ActiveWindow.Close
Next c
turns out the error is occuring ebcause the new work book i made workbook.add is made in compatability mode with excel 2003 which has a limit of 65536 rows. and the range im trying to paste has more rows than that. how do i add a workbook that is nto in compatability mode??
For c = 1 To Round(z / x + 0.5)
Rows("9:" & x).Select
Selection.Copy
Workbooks.Add
Range("A9").Select
ActiveSheet.Paste
'Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.ActivateNext
Selection.Delete
Rows("1:8").Copy
ActiveWindow.ActivatePrevious
Range("A1").Select
ActiveSheet.Paste
'Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E3") = c
ActiveWorkbook.SaveAs Filename:=FileLocation2 & "\" & g & "-" & c _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ThisWorkbook.Save
ActiveWindow.Close
Next c
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试在粘贴之前不选择每个单元格? (在 vba 中使用之前,您不需要选择每个单元格) - 如果您只想复制值,则不需要复制/粘贴(速度非常非常慢)
Did you try without selecting each cell before pasting? (you don't need to
select
every cell before using it in vba) - and you don't need to copy / paste if you only want to copy the value (it is very very slow)所以我解决了这个问题。这是添加工作簿的问题。另存为 .xlsx 或其他格式。然后在我粘贴任何内容之前重新打开它。这将使新添加的工作簿脱离兼容模式。
谢谢大家的帮助!
So i fixed the problem. it was a matter of adding the workbook. saving as .xlsx or whatever. and then reopening it before i paste anything to it. this takes the newly added workbook out of compatability mode.
Thank you everyone for your help!