shawleigh17
Board Regular
- Joined
- Nov 16, 2007
- Messages
- 79
I am trying to write code in a sheet whenever that sheet is changed, but I only want this sheet to be affected, and no others. This sheet is deleted/recreated with each run of the larger program, so I can't really have standing code in the sheet file. Is there a way to do this? I want the sheet to essentially do this: When I change a value in the "From Location" column (B), I want column A to update with the vlookup value.
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If (Sh = Workbooks("WAT_File_Existence_Test.xls").Sheets("Print_Sheet")) Then
Workbooks.Open ("D:\Personal\O&S_Report.xls")
Sheets("SKU_Change_Plan").Visible = True
Sheets("SKU_Change_Plan").Unprotect ("fritoIPM")
ActiveCell.Offset(0, -1).FormulaR1C1 = "l;l,"
Dim O_S_Value As Boolean
O_S_Value = ThisWorkbook.Sheets("Velocity").Range("A9")
If O_S_Value = "True" Then
Descrp = Application.WorksheetFunction.VLookup(ActiveCell.Value, Workbooks("O&S_Report.xls").Sheets("SKU_Change_Plan").Range("All_Data"), 4, False)
Else
Descrp = Application.WorksheetFunction.VLookup(ActiveCell.Value, Workbooks("O&S_Report.xls").Sheets("SKU_Change_Plan").Range("All_Data"), 4, False)
End If
Application.DisplayAlerts = False
Workbooks("O&S_Report.xls").Activate
Sheets("SKU_Change_Plan").Protect ("fritoIPM")
ActiveWorkbook.SaveAs ("D:\Personal\O&S_Report.xls")
ActiveWorkbook.Close
Application.DisplayAlerts = True
End If
End Sub