Reputation: 2185
I am trying to set the value of a cell with one of the function parameters. The code is giving an error 91. The 6th line in the code is raising the error:
Thanks in advance.
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
The error line is:
ws_dst.Cells(r_row, 2).Value =a
Upvotes: 2
Views: 5609
Reputation:
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
Upvotes: 2