ActiveCell Formula based on changing source file

LxGwy

New Member
Joined
Oct 31, 2012
Messages
6
Each Month my file name and path changes.
How can I code the formula to look in the correct file.
this gets me close but the error returne
'this is as close as I've gotten
' "IFERROR(VLOOKUP(A2,'M:\MyWork\[Monthly Data]Monthly Data'!L:CR,85,0),""))
' This is the formula that works when I manually type it in
' "=IFERROR(VLOOKUP(A2,'M:\MyWork\[2014 - 09 September Updated File.xlsm]Monthly Data'!L:CR,85,0),"""")"


'=here is my code...sorry to be so confusing.==========================================================
Dim Lastrow As Long
'=Where M:\MyWork\2014 09-September\2014 - 09 September Updated File.xlsm
MissesFileFolder = Format(Now(), "YYYY" & " " & "MM" & "-" & "MMMM") & "\"
MissesFileMonth = Format(Now(), "YYYY" & " - " & "MM" & " " & "MMMM") & " Missed Lines"
FileNameBase = "M:\Denver Tracking\"
FileFolder = MissesFileFolder
FileMonth = MissesFileMonth
FileSuffix = ".xlsm"
CompleteFileName = FileNameBase & FileFolder & FileMonth & FileSuffix
Workbooks.Open (CompleteFileName), UpdateLinks:=0

ThisTab = ActiveSheet.Name
FinalRow = Worksheets(ThisTab).Cells(Rows.Count, 1).End(xlUp).Row

Range("H2").Select
ActiveCell.Formula = "=IFERROR(VLOOKUP(A5,'" & FileFolder & FileMonth & "Monthly Data'!L:CR,85,0),"""")"
'=end=======================================================================================================
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,651
Messages
5,838,577
Members
430,557
Latest member
MK15

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
Top