Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Using Range().Formula with a Filename & Path

I'm apparently missing the proper syntax or method of using a string in
formulas that the VB code pastes in one spreadsheet
([WorkBook2.xls]CombList'!$E7 through $E25 one at a time) referencing values
in the corresponding cell location in another spreadsheet
(WorkBook1.xls]CombList'!$E7 through $E25 one at a time).

Each workday a new WorkBook is created (e.g. WorkBook2.xls) that has
formulas comparing E7 in today's WorkBook to the same cells on the prior
workday's values (e.g. WorkBook1.xls). For example, I want to use VB to
paste a formula in F7 showing the prior workday's value from E7 (e.g. a
formula that sets ([WorkBook2.xls]CombList'!$F7 equal to
WorkBook1.xls]CombList'!$E7). The filenames and folder locations can vary
depending on not only the workday but also which project is being tracked.

My code excerpt is shown below.
It bombs off at the statement: Range("F7").Formula = FormulaString

Any help for this novice VB programmer?


Dim LinkFN As String
Dim FormulaString As String

' Get path and filename to the file that you want to compare this Hit List
to
LinkFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls),
*.xls", Title:="Please select the Excel file that you want to compare today's
List against.")
If LinkFN = "False" Then
MsgBox "No file selected. You must select a file"
Exit Sub
End If

FormulaString = "=" & LinkFN & "CombList'!E7"
Range("F7").Formula = FormulaString

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 459
Default Using Range().Formula with a Filename & Path

BJTex wrote:
I'm apparently missing the proper syntax or method of using a string
in formulas that the VB code pastes in one spreadsheet
([WorkBook2.xls]CombList'!$E7 through $E25 one at a time) referencing
values in the corresponding cell location in another spreadsheet
(WorkBook1.xls]CombList'!$E7 through $E25 one at a time).

Each workday a new WorkBook is created (e.g. WorkBook2.xls) that has
formulas comparing E7 in today's WorkBook to the same cells on the
prior workday's values (e.g. WorkBook1.xls). For example, I want to
use VB to paste a formula in F7 showing the prior workday's value
from E7 (e.g. a formula that sets ([WorkBook2.xls]CombList'!$F7 equal
to WorkBook1.xls]CombList'!$E7). The filenames and folder locations
can vary depending on not only the workday but also which project is
being tracked.

My code excerpt is shown below.
It bombs off at the statement: Range("F7").Formula = FormulaString

Any help for this novice VB programmer?


Dim LinkFN As String
Dim FormulaString As String

' Get path and filename to the file that you want to compare this
Hit List to
LinkFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls),
*.xls", Title:="Please select the Excel file that you want to compare
today's List against.")
If LinkFN = "False" Then
MsgBox "No file selected. You must select a file"
Exit Sub
End If

FormulaString = "=" & LinkFN & "CombList'!E7"
Range("F7").Formula = FormulaString



Try to modify in this way:

FormulaString = "='[" & LinkFN & "]CombList'!E7"

and I think you can also use (but I'm not sure...)

Range("F7").Value instead of Range("F7").Formula



--
(I'm not sure of names of menus, options and commands, because
translating from the Italian version of Excel...)

Hope I helped you.

Thanks in advance for your feedback.

Ciao

Franz Verga from Italy


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i display the Filename without the path? robert_manic Excel Discussion (Misc queries) 3 October 11th 06 05:47 PM
Pulling in the path to a filename Pradhan Excel Worksheet Functions 5 November 8th 05 02:36 AM
Are there template footers for "Filename and Path" in Excel. How? Barb22 Excel Discussion (Misc queries) 1 October 10th 05 09:04 AM
Excel 2K: Putting Filename & path in footer FinChase Excel Discussion (Misc queries) 1 March 14th 05 08:12 PM
Footer - FileName and Path bill_morgan_3333 Excel Discussion (Misc queries) 6 December 30th 04 01:47 AM


All times are GMT +1. The time now is 10:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"