Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Code To Insert Cell Reference

The following line opens the macro "Recalculate" in the file "Template.xls":
Application.Run "'Template.xls'!Recalculate"
The problem is the name of the file often changes. That change is recorded
in cell "C27" of worksheet "Customize". Can someone tell me the code to have
the line reference this cell? I've tried many variations of:
Application.Run "'" & Sheets("Customize").Range("C27").Value &
"'!Recalculate" with no luck. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Code To Insert Cell Reference

Application.Run Sheets("Customize").Range("C27").Value&"!Recalcula te"

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Carl Bowman" wrote in message
...
The following line opens the macro "Recalculate" in the file
"Template.xls":
Application.Run "'Template.xls'!Recalculate"
The problem is the name of the file often changes. That change is recorded
in cell "C27" of worksheet "Customize". Can someone tell me the code to
have
the line reference this cell? I've tried many variations of:
Application.Run "'" & Sheets("Customize").Range("C27").Value &
"'!Recalculate" with no luck. Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Code To Insert Cell Reference

Niek,
Thanks for taking the time to answer. I tried an exact copy of your code but
it did not work (syntax error). I also tried
Application.Run "'" & Sheets("Customize").Range("C27").Value &
"'!Recalculate" but it did not work either. Please advise.
Carl

"Niek Otten" wrote:

Application.Run Sheets("Customize").Range("C27").Value&"!Recalcula te"

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Carl Bowman" wrote in message
...
The following line opens the macro "Recalculate" in the file
"Template.xls":
Application.Run "'Template.xls'!Recalculate"
The problem is the name of the file often changes. That change is recorded
in cell "C27" of worksheet "Customize". Can someone tell me the code to
have
the line reference this cell? I've tried many variations of:
Application.Run "'" & Sheets("Customize").Range("C27").Value &
"'!Recalculate" with no luck. Thanks!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code To Insert Cell Reference

Should work if the hard coded version works. You are just building an
identical string to feed to the run command. there is no mystery here.

if
Application.Run "'Template.xls'!Recalculate"

works then you string

"'" & Sheets("Customize").Range("C27").Value & "'!Recalculate"

must produce "'Template.xls'!Recalculate"

And Template.xls must be open and hold the macro named Recalculate in a
general module, but that would be true for the hard coded example.
--
Regards,
Tom Ogilvy

"Carl Bowman" wrote in message
...
Niek,
Thanks for taking the time to answer. I tried an exact copy of your code

but
it did not work (syntax error). I also tried
Application.Run "'" & Sheets("Customize").Range("C27").Value &
"'!Recalculate" but it did not work either. Please advise.
Carl

"Niek Otten" wrote:

Application.Run Sheets("Customize").Range("C27").Value&"!Recalcula te"

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Carl Bowman" wrote in message
...
The following line opens the macro "Recalculate" in the file
"Template.xls":
Application.Run "'Template.xls'!Recalculate"
The problem is the name of the file often changes. That change is

recorded
in cell "C27" of worksheet "Customize". Can someone tell me the code

to
have
the line reference this cell? I've tried many variations of:
Application.Run "'" & Sheets("Customize").Range("C27").Value &
"'!Recalculate" with no luck. Thanks!






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Code To Insert Cell Reference

Niek,
I finally got the following to work:
Application.Run "'" & Sheets("Customize").Range("C17").Value & "'!Recalculate
I had to switch back to the correct workbook so it could find the worksheet
"Customize".
Thanks!

"Niek Otten" wrote:

Application.Run Sheets("Customize").Range("C27").Value&"!Recalcula te"

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Carl Bowman" wrote in message
...
The following line opens the macro "Recalculate" in the file
"Template.xls":
Application.Run "'Template.xls'!Recalculate"
The problem is the name of the file often changes. That change is recorded
in cell "C27" of worksheet "Customize". Can someone tell me the code to
have
the line reference this cell? I've tried many variations of:
Application.Run "'" & Sheets("Customize").Range("C27").Value &
"'!Recalculate" with no luck. Thanks!






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code To Insert Cell Reference

I had to switch back to the correct workbook
No you don't. You just have to reference it. Assume it is in a workbook
name test.xls

Application.Run "'" & Worksheets("Test.xls").Sheets("Customize") _
.Range("C17").Value & "'!Recalculate"

Of couse if it was in cell C17 rather than C27, that would make a difference
as well.

--
Regards,
Tom Ogilvy

"Carl Bowman" wrote in message
...
Niek,
I finally got the following to work:
Application.Run "'" & Sheets("Customize").Range("C17").Value &

"'!Recalculate
I had to switch back to the correct workbook so it could find the

worksheet
"Customize".
Thanks!

"Niek Otten" wrote:

Application.Run Sheets("Customize").Range("C27").Value&"!Recalcula te"

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Carl Bowman" wrote in message
...
The following line opens the macro "Recalculate" in the file
"Template.xls":
Application.Run "'Template.xls'!Recalculate"
The problem is the name of the file often changes. That change is

recorded
in cell "C27" of worksheet "Customize". Can someone tell me the code

to
have
the line reference this cell? I've tried many variations of:
Application.Run "'" & Sheets("Customize").Range("C27").Value &
"'!Recalculate" with no luck. Thanks!






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Code To Insert Cell Reference

Your answer worked! Thanks again.

"Tom Ogilvy" wrote:

I had to switch back to the correct workbook

No you don't. You just have to reference it. Assume it is in a workbook
name test.xls

Application.Run "'" & Worksheets("Test.xls").Sheets("Customize") _
.Range("C17").Value & "'!Recalculate"

Of couse if it was in cell C17 rather than C27, that would make a difference
as well.

--
Regards,
Tom Ogilvy

"Carl Bowman" wrote in message
...
Niek,
I finally got the following to work:
Application.Run "'" & Sheets("Customize").Range("C17").Value &

"'!Recalculate
I had to switch back to the correct workbook so it could find the

worksheet
"Customize".
Thanks!

"Niek Otten" wrote:

Application.Run Sheets("Customize").Range("C27").Value&"!Recalcula te"

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Carl Bowman" wrote in message
...
The following line opens the macro "Recalculate" in the file
"Template.xls":
Application.Run "'Template.xls'!Recalculate"
The problem is the name of the file often changes. That change is

recorded
in cell "C27" of worksheet "Customize". Can someone tell me the code

to
have
the line reference this cell? I've tried many variations of:
Application.Run "'" & Sheets("Customize").Range("C27").Value &
"'!Recalculate" with no luck. Thanks!






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
INSERT OBJECT BASED ON CELL REFERENCE Gwen's Rose Excel Worksheet Functions 2 August 1st 07 02:32 AM
Can I insert a cell reference into a block of text? painterpat Excel Discussion (Misc queries) 2 June 12th 06 11:31 AM
How can I insert a cell reference in a footer (eg for variable foo wngg001 Excel Discussion (Misc queries) 1 December 15th 04 10:56 AM
Need code to insert cell value Steve Excel Programming 0 October 1st 04 12:00 AM
need code to insert cell value Steve Excel Programming 1 September 30th 04 11:38 PM


All times are GMT +1. The time now is 08:47 PM.

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

About Us

"It's about Microsoft Excel"