复制Excel工作表

时间:2017-03-15 15:52:51

标签: excel vba

我有一张excel表格,我在其中添加了有关不同项目的数据。我可以有1-10件物品。每个项目都附加了一组不同的值,并且必须为具有指定值的每个项目创建报告。我在excel文件中包含不同工作表中的所有值。我创建了一个包含报告的额外工作表。该报告将值连接到其中。

我正在尝试复制每个项目的模板报告,并更改报告中的值以匹配正确的项目。我有一个循环,可以创建正确数量的特定报告,但我无法弄清楚如何在复制报告时让循环插入正确的值。我是VBA的新手并且正在努力学习。这就是我到目前为止所拥有的。

Private Sub Creating_New_Sheet()

    Dim i As Integer



    For i = 1 To Range("I4")

    Sheets(5).Copy After:=Sheets(Sheets.Count)
    Sheets(Sheets.Count).Name = "Well" & " " & i

        Sheets(Sheets.Count).Active
        Range("B8").Select
        ActiveCell.FormulaR1C1 = "=""RE:""&""         ""&'Cost Summary'!RC[-1]"
        Range("B11").Select
        ActiveCell.FormulaR1C1 = _
            "=""Attached for your review and approval is AFE""&"" ""&'Cost Summary'!R[-3]C[7]&"" ""&""to install plunger lift on the"" &"" ""& 'Cost Summary'!R[-3]C[-1]&"". ""& ""The AFE amount is reflected in the Expenditures section of the AFE."""
        Range("B13").Select
        ActiveCell.FormulaR1C1 = _
            "=""Objective: The purpose of this workover is to install plunger lift on the""&"" ""& 'Cost Summary'!R[-5]C[-1]&"" ""& ""to stabilize production decline. Artificial lift intervention is required because gas rates for the""&"" ""& 'Cost Summary'!R[-5]C[-1]&"" ""& ""are no longer sufficient to adequately lift reservoir fluid from the wellbore.  If no intervention acti" & _
            "ken fluid will buildup in the wellbore adversely affecting the wells production and decline characteristics."""
        Range("B15").Select
        ActiveCell.FormulaR1C1 = _
            "=""Attached you will find a detailed cost estimate for plunger lift system installations on the"" &"" ""& 'Cost Summary'!R[-7]C[-1]&""""&"". Cost estimates were made using price sheets for material and services.  All other costs were estimated based on past plunger installation costs."""
        Range("B17").Select
        ActiveCell.FormulaR1C1 = _
            "=""Well History:""&"" ""& 'Cost Summary'!R[-9]C[-1]&"" ""& ""was turned to sales on""&"" ""& TEXT('Production and Well History'!R[-12]C[1],""MM/DD/YY"")&"" ""& ""and has produced for"" &"" ""&'Production and Well History'!R[-12]C[2]&"" ""&""days. The current production rates are""&"" ""& 'Production and Well History'!R[-12]C[3]&"" ""&""MCFD,""&"" ""&'Production and " & _
            "tory'!R[-12]C[4]&"" ""&  ""BOPD,""&"" ""& 'Production and Well History'!R[-12]C[5]&"" ""&""BWPD at wellhead pressures of"" &"" ""&'Production and Well History'!R[-12]C[6]&"" ""&""psi for casing pressure and""&"" ""& 'Production and Well History'!R[-12]C[7]&"" ""&""psi for tubing."""
        Range("B18").Select


    Next i

End Sub

0 个答案:

没有答案