我'm writing a macro to insert a row into all selected sheets and then set some of the values to equal the values in another sheet. I' ve设法使用以下代码插入行,但我只需输入'm getting stuck trying to set the values. Without a macro, I'输入是工作簿中第一个工作表的名称 .
Sub InsertRows()
'
' InsertRows Macro
' Inserts rows into all selected sheets at the same position
'
Dim CurrentSheet As Object
' Loop through all selected sheets.
For Each CurrentSheet In ActiveWindow.SelectedSheets
' Insert 1 row at row 7 of each sheet.
CurrentSheet.Range("a7:a7").EntireRow.Insert
CurrentSheet.Range("c7").Value =Input!C7 'this is not working
Next CurrentSheet
End Sub
2 回答
如果您只想要名为“输入”的工作表中的值,则可以执行以下操作:
如果你想要公式“=输入!C7”你可以这样做:
您需要使用
Formula
而不是Value
属性,并且应引用文本: