对于这个问题,我已经通过了很多答案,但是没有找到解决方案。有人可以帮忙吗?
以下代码仅在调试模式(F8)下有效,而在运行时无效。
代码:
Workbooks.Open Filename:=ThisWorkbook.Sheets(1).Range("D7").Value
Dim wb01 As Workbook
Set wb01 = ActiveWorkbook
wb01.Sheets(1).Range("B1").EntireColumn.Copy
Range("A1").Insert shift:=xlToRight
Columns("C").Delete
Range("C1").Sort key1:=Range("C1"), Order1:=xlDescending, Header:=xlYes
Dim LAROW As Long
LAROW = wb01.Sheets(1).Range("B" & Rows.Count).End(xlUp).Row
ThisWorkbook.Sheets(2).Activate
Dim Finalrow As Long
Finalrow = ThisWorkbook.Sheets(2).Range("B" & Rows.Count).End(xlUp).Row
Dim j As Integer
For j = 3 To Finalrow
On Error Resume Next
Range("F" & j).Value = WorksheetFunction.VLookup(WorksheetFunction.Trim(ThisWorkbook.Sheets(2).Range("B" & j).Value), wb01.Sheets(1).Range("A2:C" & LAROW), 2, 0)
Debug.Print
Next