View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robin Hammond[_2_] Robin Hammond[_2_] is offline
external usenet poster
 
Posts: 575
Default Put Filename Variable in Macro

David,

something like this.

Sub Test()
Dim wInput As Workbook
Dim strFile As String
strFile = ActiveSheet.Cells(1, 1).Text
Set wInput = Workbooks.Open(strFile)
End Sub

Robin Hammond
www.enhanceddatasystems.com

"David" wrote in message
...
Reposting in the Programming Section----

I have a macro that stores the full path/filename of a file that is needed
in
another macro to cell B8 on a sheet named Index. This sets the file
location
which can vary by location.
Another macro uses this file to post data to from the current workbook.
I'm
having trouble getting the macro to use the filename variable stored in
cell
B8.
Can you help? Here is the code that's in question:

Dim wbSum As Workbook, wbData As Workbook
Dim sht
Dim FName As Variant
FName = Worksheets("Index").Range("B8")
Set wbSum = FName <==Here's the problem line!
Set wbData = ActiveWorkbook
Dim iDate As Date, iValue
Dim lastcol As Long, xV As Long, xR As Long, xC As Long
Workbooks.Open (Filename)