如果单元格B54是" No",我想将单元格值从一个工作簿复制到另一个工作簿,但我的代码不起作用。
Option Explicit
Sub WorksheetLoop()
Dim WS_Count As Integer
Dim i As Integer
' Set WS_Count equal to the number of worksheets in the active workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 4 To WS_Count
If Workbooks("Finding_Master Summary and Response Template.xlsm").Worksheets(i).Range(54, 2).Value = "No" Then
Workbooks("finding Summary.xlsm").Sheets("Sheet1").Range(3, 1).Value = Workbooks("Finding_Master Summary and Response Template.xlsm").Sheets("Response Template").Range(54, 1).Value
End If
Next i
End Sub
此行不起作用
Workbooks("finding Summary.xlsm").Sheets("Sheet1").Range(3, 1).Value=Workbooks("Finding_Master Summary and Response Template.xlsm").Sheets("Response Template").Range(54, 1).Value
答案 0 :(得分:0)
请尝试以下代码:
Option Explicit
Sub WorksheetLoop()
Dim WS_Count As Integer
Dim i As Integer
' Set WS_Count equal to the number of worksheets in the active workbook.
WS_Count = ActiveWorkbook.Worksheets.count
' Begin the loop.
For i = 4 To WS_Count
If Workbooks("Finding_Master Summary and Response Template.xlsm").Worksheets(i).Cells(54, 2).Value = "No" Then
Workbooks("finding Summary.xlsm").Worksheets("Sheet1").Cells(3, 1).Value = Workbooks("Finding_Master Summary and Response Template.xlsm").Worksheets("Response Template").Cells(54, 1).Value
End If
Next i
End Sub