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
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