L
Len
Hi,
After running the codes below, it prompts error message Application
defined or object defined error and unable to solve : -
Codes extract
Sub vbVlookup()
Dim strPath As String
Dim strFilename As String
Dim strLookupSheet As String
Dim strLookupRange As String
Dim strLookupValue As String
strLookupValue = "A$3"
strPath = "D:\My Documents\P\ManagementAcct\Apr10\PYY\"
strFilename = "PYY PL Co compare1.Apr'10.xls"
strLookupSheet = "P&L - COMPANY (compare 1)"
strLookupRange = "A3:O60"
Application.ScreenUpdating = False
Workbooks.Open strPath & strFilename 'you should also trap the
case where the book is already open.
With Workbooks("PYY & PHV Monthly analysis- Apr'10.xls")
.Sheets(3).Range("B3").Formula = "=VLOOKUP(""" & strLookupValue &
""", " & "'" & strPath & "[" & strFilename & "]" & strLookupSheet &
"'!" & strLookupRange & ", 2, False)"
.Sheets(3).Range("B3").Value = .Sheets(3).Range("B3").Value
'End With
Workbooks(strFilename).Close savechanges:=False
Application.ScreenUpdating = True
End Sub
Appreciate any help
Thanks & Regards
Len
After running the codes below, it prompts error message Application
defined or object defined error and unable to solve : -
Codes extract
Sub vbVlookup()
Dim strPath As String
Dim strFilename As String
Dim strLookupSheet As String
Dim strLookupRange As String
Dim strLookupValue As String
strLookupValue = "A$3"
strPath = "D:\My Documents\P\ManagementAcct\Apr10\PYY\"
strFilename = "PYY PL Co compare1.Apr'10.xls"
strLookupSheet = "P&L - COMPANY (compare 1)"
strLookupRange = "A3:O60"
Application.ScreenUpdating = False
Workbooks.Open strPath & strFilename 'you should also trap the
case where the book is already open.
With Workbooks("PYY & PHV Monthly analysis- Apr'10.xls")
.Sheets(3).Range("B3").Formula = "=VLOOKUP(""" & strLookupValue &
""", " & "'" & strPath & "[" & strFilename & "]" & strLookupSheet &
"'!" & strLookupRange & ", 2, False)"
.Sheets(3).Range("B3").Value = .Sheets(3).Range("B3").Value
'End With
Workbooks(strFilename).Close savechanges:=False
Application.ScreenUpdating = True
End Sub
Appreciate any help
Thanks & Regards
Len