通过粘贴特殊的xlpastevalues和xlpasteformats组合多个工作表

时间:2018-08-24 07:08:52

标签: vba excel-vba

我一直试图将多张纸合并为一张。我已经完成了,但是当我尝试添加一行代码

function calculate() {
  var myBox1 = updateValue('box1');
  var myBox2 = updateValue('box2');
  var myResult = myBox1 * myBox2;
  adTextRes('result', myResult)
}

function updateValue(nameOf) {
  var inputNo = document.getElementById(nameOf).value;
  var no = createNo(inputNo);
  adTextRes(nameOf, no);
  return no;
}

function adTextRes(nameOf, no) {
  var asText = String(no).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  document.getElementById(nameOf).value = asText;
}

function createNo(textin) {
  return textin
    .replace(/,/g, "")
    .replace(/(\.\d*)\./, '$1')
}

它使我的工作表空白。这是代码

<table width="80%" border="0">
  <tr>
    <th>Box 1</th>
    <th>Box 2</th>
    <th>Result</th>
  </tr>
  <tr>
    <td><input id="box1" type="text" oninput="calculate()" /></td>
    <td><input id="box2" type="text" oninput="calculate()" /></td>
    <td><input id="result" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

1 个答案:

答案 0 :(得分:2)

像这样使用

Selection.Copy

Sheets("Consolidated").Cells(Rows.Count, 1).End(xlUp)(3).PasteSpecial (xlPasteFormats)

Sheets("Consolidated").Cells(Rows.Count, 1).End(xlUp)(3).PasteSpecial (xlPasteValues)