I am new to VBA and trying to create a macro in VBA based on the following.
XLookup to count columns going backwards instead of a Vlookup. Once the formula finds the cell, then I would like to replace it with a number entered into an input box.
Here is what I tried. I know the replace with line is incorrect. I am able to return a value for the Xlookup. I just can't figure out the correct piece to add in the replacewith line.
Sub Macro2()
'
' Macro2 Macro
'
Dim myValue As Variant
myValue = InputBox("Enter Club Number")
Range("A1").Value = myValue
myValue2 = InputBox("Enter UNL, PREM, or DSL")
Range("B1").Value = myValue2
Range("C1").Value = Range("A1").Value & Range("B1")
Dim Lookup_Value As String
Dim Lookup_Array As Range
Dim Return_Array As Range
Dim If_Not_Found As String
Dim Result As Variant
Lookup_Value = Range("A1").Value & Range("B1")
Set Lookup_Array = Range("O:O")
Set Return_Array = Range("D:D")
If_Not_Found = "N/A"
On Error GoTo CompatibilityIssue
Result = Application.WorksheetFunction.XLookup( _
Lookup_Value, _
Lookup_Array, _
Return_Array, _
If_Not_Found)
replacewith.InputBox ("Enter New Price")
Exit Sub
CompatibilityIssue:
MsgBox "It does not appear that you have access to the XLOOKUP Function"
End Sub