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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,219,162
Messages
6,146,660
Members
450,706
Latest member
LGVBPP

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