当前位置: 动力学知识库 > 问答 > 编程问答 >

excel - Simple copy of formula from 1 worksheet to another without getting a #ref error

问题描述:

This should be I hope a simple question.

I have a simple formula in a cell, worksheet name is Entry

=Entry!D10

I have 5 cells all with similar formulas in them. I want to be able to push a form button and copy the results from these formulas to a new row on another worksheet.

网友答案:

Here is an example to port across formulas without getting the #ref error

Sub Sample()
    Dim ws1 As Worksheet, ws2 As Worksheet

    Set ws1 = ThisWorkbook.Sheets("Sheet1")
    Set ws2 = ThisWorkbook.Sheets("Sheet2")

    ws1.Range("A1").Formula = ws2.Range("C1").Formula
    ws1.Range("D1").Formula = ws2.Range("F1").Formula
End Sub
分享给朋友:
您可能感兴趣的文章:
随机阅读: