vba excel在vba中粘贴特殊功能不粘贴单元格宽度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16862565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 21:23:26  来源:igfitidea点击:

excel paste special function in vba not pasting cell widths

excelvbaexcel-vbaexcel-2007

提问by impactblu

I'm running a macro to copy from one sheet and past to another however, it is not pasting the cell width. If I do this manually it works i.e. copy the column and paste special > all. the vba code for the macro is located here: http://pastebin.com/K2sW1C8x

我正在运行一个宏来从一张纸复制并粘贴到另一张纸,但是,它没有粘贴单元格宽度。如果我手动执行此操作,它会起作用,即复制列并粘贴特殊 > 全部。宏的 vba 代码位于:http: //pastebin.com/K2sW1C8x

as you can see i'm using :

如您所见,我正在使用:

Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _False, Transpose:=False

回答by chuff

The paste of the column widths need to be done in a separate action:

列宽的粘贴需要在单独的操作中完成:

  Selection.PasteSpecial Paste:=xlColumnWidths

This command occasionally threw an error in previous versions of Excel. If you get an error, use the number 8 in place of xlColumnwidths.

此命令有时会在以前版本的 Excel 中引发错误。如果出现错误,请使用数字 8 代替 xlColumnwidths。