使用VBA链接来自不同工作表的单元格

时间:2018-09-07 15:26:33

标签: excel vba excel-vba

我在将工作表之间的值与VBA链接时遇到一些麻烦。我能够将值从新创建的工作表复制到我的“输入”工作表中,但是当更改新创建的工作表中的值时,“输入”工作表中的值不变。有谁可以帮助我解决这个问题。到目前为止,这是我的代码(请注意第3至最后一段):

financing = ws.Range("F2").Value
compName = ws.Range("F3").Value
fortnr = compName & "-" & financing

lastRow = ws.Cells(Rows.Count, "B").End(xlUp).Row + 1
ws.Cells(lastRow, "B") = financing
ws.Cells(lastRow, "C") = compName

ActiveWorkbook.Worksheets("Template").Copy After:=Worksheets("Template")
ActiveWorkbook.Sheets("Template").Name = compName & "-" & financing
ActiveWorkbook.Sheets(compName & "-" & financing).Visible = xlSheetVisible

ActiveWorkbook.Sheets("Template (2)").Name = "Template"

ActiveWorkbook.Sheets(fortnr).Select

ActiveWorkbook.Sheets(fortnr).Range("B3").Value = financing
ActiveWorkbook.Sheets(fortnr).Range("B4").Value = compName

ws.Cells(lastRow, "D") = Sheets(fortnr).Range("B6").Value
ws.Cells(lastRow, "E") = Sheets(fortnr).Range("B7").Value

ActiveSheet.Hyperlinks.Add Anchor:=ws.Cells(lastRow, 1), Address:="", 
SubAddress:= _
"'" & fortnr & "'" & "!A1", TextToDisplay:="Check"                                  

ActiveSheet.Hyperlinks.Add Sheets(compName & "-" & financing).Range("A1"), 
"", Sheets("INPUT").Name & "!A1", TextToDisplay:="Back to Input-sheet"

0 个答案:

没有答案