将复制数据引用到原始单元格

时间:2015-06-10 15:41:36

标签: excel vba excel-vba

我正在尝试将复制的数据引用到初始单元格。 我的序列如下

  1. 在按钮上单击// sheetname Load1,Load2等添加新闻表
  2. 将数据输入新表
  3. 点击添加新加载。
  4. 复制特定单元格
  5. 粘贴摘要表
  6. 6。将粘贴的值链接到原始工作表单元格

    我的代码

    Sub New_Load()
    
    
    Dim i As Integer
    Dim ws As Worksheet
    Dim sh As Worksheet
    Dim x1, x2, x3, x4, x5, x6, x7, x8 As Variant ' motor loads
    Dim y1, y2, y3, y4, y5 As Variant 'UPS loads ' y5 (cell C14 with white text) sheetname
    
    Set ws = Sheets("Tech_Form") '
    
    Set sh = Sheets(Sheets.Count) ' This will be the last sheet in the Workbook
    Application.ScreenUpdating = 0
    
    If Range("D15") = "UPS" Then
    
    Fill_Blanks 'fill blanks with N/A
    
    y1 = Range("D15").Value
    y2 = Range("E42").Value
    y3 = Range("H42").Value
    y4 = Range("E46").Value
    y5 = Range("C15").Value
    
    
    Sheets("Summary").Select
    
    Range("C" & Rows.Count).End(xlUp).Offset(1).Value = y1
    Range("E" & Rows.Count).End(xlUp).Offset(1).Value = y2
    Range("H" & Rows.Count).End(xlUp).Offset(1).Value = y3
    Range("I" & Rows.Count).End(xlUp).Offset(1).Value = y4
    Range("F" & Rows.Count).End(xlUp).Offset(1).Value = "kWe"
    Range("G" & Rows.Count).End(xlUp).Offset(1).Value = "N/A"
    Range("D" & Rows.Count).End(xlUp).Offset(1).Value = "N/A"
    Range("B" & Rows.Count).End(xlUp).Offset(1).Value = y5
    
    
    End If
    
    Sheets("Load").Visible = True
    Sheets("Load").Copy After:=sh
    
    
    Sheets(Sheets.Count).Name = "Load" & Sheets.Count - 4 ' number of static    sheets
    'ActiveSheet.Name = Range("D15").Value
    
    Sheets("Load").Visible = False
    
    
    End Sub
    

0 个答案:

没有答案