我正在尝试选择一个与活动单元格偏移的单元格范围,我运气不佳。我尝试选择的单元格范围在与活动单元格相同的行中的第11个单元格和第13个单元格之间,包括第11个单元格和第13个单元格。我收到以下错误:
Run-time error '1004':
Application-defined or object-defined error.
我还是VBA的新手。如果您在我的代码中发现任何其他明显的问题,请随时纠正我!错误出现在带有星号的行。
Sub TransferCells()
Dim aggrange As Range
Dim AnalyticalCell As Range
Dim BatchCell As Range
Dim analyticalwb As Excel.Workbook
Dim batchwb As Excel.Workbook
Dim SEHPLC As Worksheet
Dim CultureDay As Worksheet
Set batchwb = Workbooks.Open("\\cntusmafpsjnj.com\HomeH$\Tala Big Data\20180420_Fed Batch All Data_0.xlsx")
Set CultureDay = batchwb.Worksheets("Culture Day")
Set analyticalwb = Workbooks.Open("\\cntusmafps.com\HomeH$\Tala Big Data\Castle Analytical Results (4).xlsm")
Set SEHPLC = analyticalwb.Worksheets("SE-HPLC")
MsgBox ActiveSheet.Name
For Each AnalyticalCell In analyticalwb.Worksheets("SE-HPLC").Range("A2:A87")
For Each BatchCell In batchwb.Worksheets("Culture Day").Range("A2:A125271")
If AnalyticalCell.Value = BatchCell.Value Then
MsgBox ActiveCell.Address
**'Set aggrange = Range((ActiveCell.Offset(0, 11)), (ActiveCell.Offset(0, 13)))'
ActiveCell.Offset(0, 11).Resize(0, 13).Select**
aggrange.Copy Destination:=Application.Workbooks("20180420_Fed Batch All Data_0.xlsx").Worksheets("Sheet3").Range(BatchCell.Offset(0, 3), BatchCell.Offset(0, 5))
End If
Next BatchCell
Next AnalyticalCell
End Sub