大家好,我对vba完全不熟悉,我正在尝试使用其中一个函数参数设置单元格的值。代码给出错误91.代码中的第6行引发错误。我无法解决,请任何人帮助我。
提前致谢。
Sub report_file(a, r_row)
Dim wb_dst As Workbook
Dim ws_dst As Worksheet
Set wb_dst = Workbooks.Open("F:\Projects\vba_excel\report.xlsx")
ws_dst = wb_dst.Sheets(1)
ws_dst.Cells(r_row, 2).Value =a
End Sub
错误行是。
ws_dst.Cells(r_row, 2).Value =a
答案 0 :(得分:2)
Option Explicit
Sub report_file(a, r_row)
Dim wb_dst As Workbook
Dim ws_dst As Worksheet
Set wb_dst = Workbooks.Open("F:\Projects\vba_excel\report.xlsx")
Set ws_dst = wb_dst.Sheets(1)
ws_dst.Cells(r_row, 2).Value = a
If a = "savior" Then
wb_dst.Cells(r_row, 2).Value = a
End If
End Sub