Code:
Dim wb_FWD As Workbook, wb_AFT As Workbook, ws_FWD As Worksheet, ws_AFT As Worksheet
Dim MEAS_wb As Workbook, MEAS_ws As Worksheet, SN_ws As Worksheet, SNL_ws As Worksheet
Set MEAS_wb = ActiveWorkbook
Set MEAS_ws = MEAS_wb.Worksheets("Measurements")
Set SN_ws = MEAS_wb.Worksheets("Sheet1")
Set SNL_ws = MEAS_wb.Worksheets("SN_List")
flpath = SN_ws.Range("B1").Value
fl_pth1 = flpath & "\something_PROD_OPA_J-"
fl_pth2 = flpath & "\something_PROD_OPB_J-"
SN_ws.Activate 'issue numbers
a_iss = Format(SN_ws.Range("B2").Value, "Standard")
b_iss = Format(SN_ws.Range("B3").Value, "Standard")
a_path = fl_pth1 & a_iss & ".xlsx"
b_path = fl_pth2 & b_iss & ".xlsx"
Set wb_FWD = Workbooks.Open(a_path)
Set ws_FWD = wb_FWD.Worksheets("Sheet1")
ws_FWD.Range("A1").Activate
i = 0
While Not ActiveCell = ""
i = i + 1
ActiveCell.Offset(1, 0).Activate
Wend
SNL_ws.Activate
SNL_ws.Range("A1").Activate
While Not ActiveCell = ""
a_sn_count = a_sn_count + 1
ActiveCell.Offset(1, 0).Activate
Wend
SNL_ws.Range("B1").Activate
While Not ActiveCell = ""
b_sn_count = b_sn_count + 1
ActiveCell.Offset(1, 0).Activate
Wend
v = 0
s = 0
For v = 2 To i
ws_FWD.Activate
ws_FWD.Range("I" & v).Activate
sn_a = ws_FWD.Range("I" & v).Value
SNL_ws.Activate
For j = 1 To a_sn_count
If sn_a = SNL_ws.Range("A" & j).Value Then GoTo skp_val
Next j
ws_FWD.Activate
feat_id = ws_FWD.Range("A" & v).Value
If feat_id = "Feature" Or feat_id = "130_REFERENCE" Then GoTo skp_val
rept_val = ws_FWD.Range("C" & v).Value
rec_sn = ws_FWD.Range("I" & v).Value
oper_id = ws_FWD.Range("J" & v).Value
MEAS_ws.Activate
MEAS_ws.Range("A" & v + s).Value = pn_nam
MEAS_ws.Range("B" & v + s).Value = feat_id
MEAS_ws.Range("C" & v + s).Value = mach_nam
MEAS_ws.Range("D" & v + s).Value = rec_sn
MEAS_ws.Range("E" & v + s).Value = L_siz
MEAS_ws.Range("F" & v + s).Value = rept_val
MEAS_ws.Range("H" & v + s).Value = rec_sn
MEAS_ws.Range("J" & v + s).Value = oper_id
MEAS_ws.Range("N" & v + s).Value = tool_num
If feat_id = "270.75" Then GoTo comp_v
GoTo v_n
skp_val:
s = s - 1
GoTo v_n
comp_v:
a_sn_count = a_sn_count + 1
SNL_ws.Activate
SNL_ws.Range("A" & a_sn_count + list_add).Value = rec_sn
vs_tot = v + s - 1
v_n:
Next v
'need to clean out file for FWD here
wb_FWD.Close
When I am attempting to close the recently opened workbook an error is appearing:
Run-time error '-2147221080(800401a8)':
Method 'Close' of object '_Workbook' failed
I have tried multiple options and seem to be running into this similar error. This is something that I had been using in other VBA code that had functioned. Does anyone know an alternate method to close the specific workbook?
Thank you