简体   繁体   English

复制Excel范围并在VBScript中仅将值(pasteSpecial)粘贴为跳空白

[英]Copy excel range and paste only values (pasteSpecial) with skip blanks in VBScript

I need to copy some range of excel from a sheet of source excel file and paste it to a sheet of a target excel file by skipping the blank cells copied from the source excel file. 我需要通过跳过从源excel文件复制的空白单元格,从一张源excel文件中复制一定范围的excel,然后将其粘贴到目标excel文件中。

The below code is working fine in VBA, how to write equivalent code in VBScript? 下面的代码在VBA中工作正常,如何在VBScript中编写等效代码?

Selection.Copy
Sheets("Sheet1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=True, Transpose:=False

I know the code for paste special with only values is "-4163". 我知道仅特殊值粘贴特殊代码是“ -4163”。 Below snippet is working fine in this case, 在这种情况下,以下代码段可以正常运行,

sourceWorkbook.Worksheets(1).UsedRange.Copy
targetWorkbook.Worksheets(1).Range("A1").PasteSpecial -4163

But i need it to paste values and skip blank copied cells (ie do not want to overwrite or replace with the cells of copied range). 但是我需要它粘贴值并跳过空白的复制单元格(即,不想覆盖或替换复制范围的单元格)。 How to achieve this?? 如何实现这一目标?

Any help will be greatly appreciated 任何帮助将不胜感激

Hi Ranjan Finally some how we got it resolves the right way to use the paste special in vb script is 嗨,Ranjan最后,我们了解到如何解决在vb脚本中使用特殊粘贴的正确方法是

Selection.PasteSpecial -4163, -4142, True, False Selection.PasteSpecial -4163,-4142,True,False

-4163 - for XlPastValues -4142 - for Operation:= xlNone True - For skip Blanks False - Transpose -4163-适用于XlPastValues -4142-适用于操作:= xlNone true-适用于跳过空白False-移调

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM