When running this code below the VBE highlights ImportSheetRange in this line: "ReturnValue = Indexmatch(strSKUEntered, ImportSheetRange, ExportSheetRange)" and spits the error "ByRef argument type mismatch".
Any help.
Running Excel 365 / Window 7.
Thanks!
Any help.
Running Excel 365 / Window 7.
Thanks!
Code:
Option Explicit
Sub Macro1()
Dim kpResults, datExportDate, strImportDate1, strImportDate2, strSKUEntered As String
Dim ImportSheetRange, ExportSheetRange As Range
Dim ReturnValue As Variant
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
.DisplayAlerts = False
End With
'Prompt for SKU - provide default value as a guide/mask and allow to click on SKU in spreadsheet instead of typing in value
strSKUEntered = Application.InputBox("Enter a SKU to process", , "242738-797-REM", , , , Type:=2)
'Find SKU on Export Worksheet, write -3 columns cell value (Date) to a variable
'Worksheet function formula in SS = =INDEX(Import!$A$2:$O$250000,SMALL(IF(Import!$A:$A=$D$452,ROW($A:$A)),ROW(1:1))-1,15)
Set ImportSheetRange = ActiveWorkbook.Sheets("Import").Range("A2:P100000")
Set ExportSheetRange = ActiveWorkbook.Sheets("Export").Range("A2:E100000")
ReturnValue = Indexmatch(strSKUEntered, ImportSheetRange, ExportSheetRange)
Debug.Print ReturnValue
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.DisplayAlerts = True
End With
End Sub
Function Indexmatch(LookFor As String, SearchRng As Range, ReturnRng As Range) As Variant
Application.Volatile
Indexmatch = WorksheetFunction.Index(ReturnRng, WorksheetFunction.Match(LookFor, SearchRng, 0), 0)
End Function