Dear forum,
I have a macro running all fine until a point where I have code to add dropdown "Active, Inactive" option to column BK. The macro runs up to the naming of cell BK1. It stops there and doesn't execute the dropdown code. However, if I run just the dropdown code only in another workbook, the code runs fine. Could the problem be because the macro is bulky or lengthy?
The macro can be found below:
Your opinion and input are very much appreciated. Thank you so much.
I have a macro running all fine until a point where I have code to add dropdown "Active, Inactive" option to column BK. The macro runs up to the naming of cell BK1. It stops there and doesn't execute the dropdown code. However, if I run just the dropdown code only in another workbook, the code runs fine. Could the problem be because the macro is bulky or lengthy?
The macro can be found below:
Your opinion and input are very much appreciated. Thank you so much.
VBA Code:
Sub Orders()
Dim wb As Workbook
Dim ws As Worksheet
Dim nws As Worksheet
Dim rng As Range
Dim rng2 As Range
Dim rng3 As Range, FinalResult As Variant
Dim rng4 As Range
Dim rng5 As Range, FinalResult2 As Variant
Dim rng6 As Range
Dim rng7 As Range
Dim rng8 As Range
Dim rng9 As Range
Dim rng10 As Range
Dim rng11 As Range
Dim rng12 As Range
Dim rng13 As Range
Dim rng14 As Range
Dim rng15 As Range
Dim rng16 As Range
Dim rng17 As Range
Dim rng18 As Range
Dim rng19 As Range
Dim rng20 As Range, FinalResult3 As Variant
Dim Path1 As String
Dim Path2 As String
Dim Path3 As String
Dim wbx As Workbook
Dim wsx As Worksheet
Dim wby As Workbook
Dim wsy As Worksheet
Dim wbz As Workbook
Dim wsz As Worksheet
Dim Table1 As Range
Dim Table2 As Range
Dim Table3 As Range
Dim Table4 As Range
Dim Table5 As Range
Dim Table6 As Range
Dim UsdRws As Long
Set wb = ThisWorkbook
Set ws = wb.Worksheets("Sheet1")
Set rng = ws.Range("A2").CurrentRegion
Path1 = "M:\Pricing\Pricing Sheet.xlsx"
Set wbx = Workbooks.Open(Filename:=(Path1), Password:="ye&wL1SLPTdwGlg3Rtd", _
ReadOnly:=True, IgnoreReadOnlyRecommended:=True)
Set wsx = wbx.Worksheets("Price")
wsx.Range("A:A").Copy Destination:=ws.Range("A:A")
wsx.Range("B:B").Copy Destination:=ws.Range("B:B")
wsx.Range("C:C").Copy Destination:=ws.Range("C:C")
wsx.Range("D:D").Copy Destination:=ws.Range("D:D")
wsx.Range("AE:AE").Copy Destination:=ws.Range("E:E")
wsx.Range("Q:Q").Copy Destination:=ws.Range("F:F")
wsx.Range("E:E").Copy Destination:=ws.Range("G:G")
wsx.Range("F:F").Copy Destination:=ws.Range("H:H")
wbx.Close
Path2 = "M:\Data Upload Prep\Latest Master Data sheet\Master Data Sheet.xlsx"
Set wby = Workbooks.Open(Path2)
Set wsy = wby.Worksheets("Master")
wsy.Range("A:A").Copy Destination:=ws.Range("I:I")
wsy.Range("B:B").Copy Destination:=ws.Range("J:J")
wby.Close
wb.SaveCopyAs Filename:="M:\FBA\Automation\1. IN\channeladvisor_export " & Format(Now(), "dd.mm.yyyy") & ".xls"
Path3 = "M:\FBA\Automation\1. IN\channeladvisor_export " & Format(Now(), "dd.mm.yyyy") & ".xls"
Set wbz = Workbooks.Open(Path3)
Set wsz = wbz.Worksheets("Sheet1")
Set rng2 = wsz.Range("AX1")
rng2.Value = "Min " & "FBA " & "Price"
Set Table1 = wsz.Range(wsz.Range("A2"), wsz.Range("A2").End(xlDown))
Set Table2 = ws.Range(ws.Range("A2:G2"), ws.Range("A2:G2").End(xlDown))
Set rng3 = wsz.Range(wsz.Range("AX2:AX2"), wsz.Range("AX2:AX2").End(xlDown))
FinalResult = Application.WorksheetFunction.VLookup(Table1, Table2, 7, False)
rng3 = FinalResult
wsz.UsedRange.Replace "#N/A", "", lookat:=xlWhole
Set rng4 = wsz.Range("AY1")
rng4.Value = "Max " & "FBA " & "Price"
Set Table3 = wsz.Range(wsz.Range("A2"), wsz.Range("A2").End(xlDown))
Set Table4 = ws.Range(ws.Range("A2:H2"), ws.Range("A2:H2").End(xlDown))
Set rng5 = wsz.Range(wsz.Range("AY2:AY2"), wsz.Range("AY2:AY2").End(xlDown))
FinalResult2 = Application.WorksheetFunction.VLookup(Table3, Table4, 8, False)
rng5 = FinalResult2
wsz.UsedRange.Replace "#N/A", "", lookat:=xlWhole
Set rng6 = wsz.Range("AZ1")
rng6.Value = "Buy " & "Box " & "Eligible"
Set rng7 = wsz.Range(wsz.Range("AZ2:AZ2"), wsz.Range("AZ2:AZ2").End(xlDown))
rng7.Formula = "=IF(F2=""No Buy Box on ASIN"",""No"",""Yes"")"
Set rng8 = wsz.Range("BA1")
rng8.Value = "Amz " & "and " & "MBAC " & "difference"
Set rng9 = wsz.Range(wsz.Range("BA2:BA2"), wsz.Range("BA2:BA2").End(xlDown))
rng9.Formula = "=IF(W2="""",""Yes"",IF(W2=""Out of Stock"",""Yes"",IF(((AX2-W2)/AX2)<0,""Yes"",""No"")))"
Set rng10 = wsz.Range("BB1")
rng10.Value = "FBA " & "and " & "MBAC " & "difference"
Set rng11 = wsz.Range(wsz.Range("BB2:BB2"), wsz.Range("BB2:BB2").End(xlDown))
rng11.Formula = "=IF(V2="""",""Yes"",IF(V2=""Out of Stock"",""Yes"",IF(((AX2-V2)/AX2)<0.01,""Yes"",""No"")))"
Set rng12 = wsz.Range("BC1")
rng12.Value = "SFP " & "and " & "MBAC " & "difference"
Set rng13 = wsz.Range(wsz.Range("BC2:BC2"), wsz.Range("BC2:BC2").End(xlDown))
rng13.Formula = "=IF(X2="""",""Yes"",IF(X2=""Out of Stock"",""Yes"",IF(((AX2-X2)/AX2)<0.02,""Yes"",""No"")))"
Set rng14 = wsz.Range("BD1")
rng14.Value = "Non " & "Prime " & "and " & "MBAC " & "difference"
Set rng15 = wsz.Range(wsz.Range("BD2:BD2"), wsz.Range("BD2:BD2").End(xlDown))
rng15.Formula = "=IF(Y2="""",""Yes"",IF(Y2=""Out of Stock"",""Yes"",IF(((AX2-Y2)/AX2)<0.04,""Yes"",""No"")))"
Set rng16 = wsz.Range("BE1")
rng16.Value = "Final " & "Decision " & "on " & "Sending"
Set rng17 = wsz.Range(wsz.Range("BE2:BE2"), wsz.Range("BE2:BE2").End(xlDown))
rng17.Formula = "=IF(AND(AZ2=""Yes"",BA2=""Yes"",BB2=""Yes"",BC2=""Yes"",BD2=""Yes""),""Yes"",""No"")"
Set rng18 = wsz.Range("BF1")
rng18.Value = "Quantity " & "to " & "Send"
UserForm1.Show vbModal
End Sub
Sub Orders1()
Dim wb As Workbook
Dim ws As Worksheet
Dim nws As Worksheet
Dim rng As Range
Dim rng19 As Range
Dim rng20 As Range, FinalResult3 As Variant
Dim rng21 As Range
Dim rng22 As Range, FinalResult4 As Variant
Dim rng23 As Range
Dim rng24 As Range
Dim rng25 As Range
Dim rng26 As Range, FinalResult5 As Variant
Dim rng27 As Range
Dim rng28 As Range
Dim Path1 As String
Dim Path2 As String
Dim Path3 As String
Dim Path4 As String
Dim wbx As Workbook
Dim wsx As Worksheet
Dim wby As Workbook
Dim wsy As Worksheet
Dim wbz As Workbook
Dim wsz As Worksheet
Dim wba As Workbook
Dim wsa As Worksheet
Dim Table5 As Range
Dim Table6 As Range
Dim Table7 As Range
Dim Table8 As Range
Dim Table9 As Range
Dim Table10 As Range
Dim UsdRws As Long
Set wb = ThisWorkbook
Set ws = wb.Worksheets("Sheet1")
Set rng = ws.Range("A2").CurrentRegion
Set wsz = Worksheets("Sheet1")
Set rng19 = wsz.Range("BG1")
rng19.Value = "Unit " & "Quantity "
Set Table5 = wsz.Range(wsz.Range("A2"), wsz.Range("A2").End(xlDown))
Set Table6 = ws.Range(ws.Range("A2:C2"), ws.Range("A2:C2").End(xlDown))
Set rng20 = wsz.Range(wsz.Range("BG2:BG2"), wsz.Range("BG2:BG2").End(xlDown))
FinalResult3 = Application.WorksheetFunction.VLookup(Table5, Table6, 3, False)
rng20 = FinalResult3
wsz.UsedRange.Replace "#N/A", "", lookat:=xlWhole
Set rng21 = wsz.Range("BH1")
rng21.Value = "LabelsUK"
Path4 = "M:\FBA\Automation\2. IN CA EXPORT\InventoryExport_7-21-2022-5-39-38-20.xlsx"
Set wba = Workbooks.Open(Path4)
Set wsa = wba.Worksheets("InventoryExport")
Set Table7 = wsz.Range(wsz.Range("A2"), wsz.Range("A2").End(xlDown))
Set Table8 = wsa.Range(wsa.Range("A2:D2"), wsa.Range("A2:D2").End(xlDown))
Set rng22 = wsz.Range(wsz.Range("BH2:BH2"), wsz.Range("BH2:BH2").End(xlDown))
FinalResult4 = Application.WorksheetFunction.VLookup(Table7, Table8, 4, False)
rng22 = FinalResult4
wsz.UsedRange.Replace "#N/A", "", lookat:=xlWhole
wba.Close
Set rng23 = wsz.Range("BI1")
rng23.Value = "Final " & "Quantity " & "to " & "Send"
Set rng24 = wsz.Range(wsz.Range("BI2:BI2"), wsz.Range("BI2:BI2").End(xlDown))
rng24.Formula = "=IF(COUNTIF(BH2,""*Amazon*""),IF(AND(BE2=""Yes"",BF2>0),BF2,""No""))"
Set rng25 = wsz.Range("BJ1")
rng25.Value = "MBAC " & "Internal " & "Title"
Set Table9 = wsz.Range(wsz.Range("A2"), wsz.Range("A2").End(xlDown))
Set Table10 = ws.Range(ws.Range("A2:D2"), ws.Range("A2:D2").End(xlDown))
Set rng26 = wsz.Range(wsz.Range("BJ2:BJ2"), wsz.Range("BJ2:BJ2").End(xlDown))
FinalResult5 = Application.WorksheetFunction.VLookup(Table9, Table10, 4, False)
rng26 = FinalResult5
wsz.UsedRange.Replace "#N/A", "", lookat:=xlWhole
Set rng27 = wsz.Range("BK1")
rng27.Value = "Status " & "Check"
Set rng28 = wsz.Range(wsz.Range("BK2:BK2"), wsz.Range("BK2:BK2").End(xlDown))
rng28.Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="Active,Inactive"
End Sub