match command in vlookup

Aqsa Butt

New Member
Joined
Sep 12, 2018
Messages
1
hi, i am new in excel vba i am trying to write a code that will use a dynamic value as the column index
i googled it and reached at this code
Dim FileName As String
Dim value As String
Dim value2 As Double
Dim value3 As Double
Dim wbName As String, wb As Workbook, ws As Worksheet
Application.ScreenUpdating = False
txt = "F:\Sapphire\excel work\MISExecutiveSummaryAugust2018Macros.xlsm"
If Dir(txt) = "" Then
MsgBox txt & " does not exist"
Else
Set wb = Workbooks.Open(txt)
On Error Resume Next
Set ws = wb.Sheets("ES Report 1")
If Not ws Is Nothing Then
MsgBox ws.Range("C23")
value = Cells(23, 3)
MsgBox (value)
wb.Close
Cells(18, 1) = value
Else
MsgBox ws.Name & " does not exist"
End If
Err.Clear
End If
Application.ScreenUpdating = True
value3 = InputBox("Enter value you want to look for")
MsgBox value3
Cells(17, 2) = value3
value2 = Application.vlookup(value, Sheet1.Range("A1:D14"), Match(value3, Range("A2:A13"), 0), False)
MsgBox ("value2 is " & value2)


it is working good except that it show the error that Sub or Function is not defined and highlights the "Match"
i dont know how to solve this
thanks in advance
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You would need to use application.match or worksheetfunction.match. You havent specified your sheet name for the range also. Its a little weird. The match can potentially return a number from 1 to 12. Your lookup range has only 4 columns. This will error if the match produces any number greater than 4. Id assume this formula is not as intended.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top