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

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,214,646
Messages
6,120,718
Members
448,986
Latest member
andreguerra

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