Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default #NAME when I insert a sheet from a template

I'm inserting a worksheet, and that worksheet is from a template file. So the code looks like

Set wks = ThisWorkbook.Worksheets.Add(NextSheet, , , "C:\MyTemplate.xlt"

This works well except for one thing: formulas in this new sheet that refer to named ranges give a #NAME error. If I click my mouse in the formula editor and press <Enter, magically the formula resolves properly. I've tried using Worksheet.Calculate and Application.Calculate, but they don't make any difference. Is there a way I can force these formulas to calcualate from code

I doesn't matter if the range is defined locally to the sheet or globally to the workbook

Thanks

James
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default #NAME when I insert a sheet from a template

Untested: Maybe you could do a replace (equal sign with equal sign) as the next
step in your code.


jstrater wrote:

I'm inserting a worksheet, and that worksheet is from a template file. So the code looks like:

Set wks = ThisWorkbook.Worksheets.Add(NextSheet, , , "C:\MyTemplate.xlt")

This works well except for one thing: formulas in this new sheet that refer to named ranges give a #NAME error. If I click my mouse in the formula editor and press <Enter, magically the formula resolves properly. I've tried using Worksheet.Calculate and Application.Calculate, but they don't make any difference. Is there a way I can force these formulas to calcualate from code?

I doesn't matter if the range is defined locally to the sheet or globally to the workbook.

Thanks,

James


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default #NAME when I insert a sheet from a template

try this

Application.CalculateFul

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default #NAME when I insert a sheet from a template

Yet another reason to hate Excel 97 - Application.CalculateFull doesn't exist. I'll transfer my project to my other machine and test it on XP, where I see the method does exist, but it doesn't do me any good today for this client. They really have to upgrade soon..

Thanks

James
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default #NAME when I insert a sheet from a template

Dave

That's a wild and crazy idea, but it sounds like it might work. To optimize I guess I'll have to do a global search/replace on .UsedRange, that would probably be the fastest

Thanks

James


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default #NAME when I insert a sheet from a template

I've never noticed any delay when I do it manually.

In xl2002, I hit ctrl-a, ctrl-h and type my stuff and hit ok.

The only damage that could happen is if you have a cell formatted as text and
have a value that begins with =, then excel will try to convert it to a formula.



jstrater wrote:

Dave,

That's a wild and crazy idea, but it sounds like it might work. To optimize I guess I'll have to do a global search/replace on .UsedRange, that would probably be the fastest.

Thanks,

James


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default #NAME when I insert a sheet from a template

Dave

It works just fine. Just to avoid replacing non-formula-starting equal signs I did a select special on formulas in the sheet

Thanks

James
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
Template;insert a page Diane Excel Discussion (Misc queries) 1 June 10th 08 06:47 PM
How do I insert template in new sheet of pre-existing excel file? frustrated Excel Worksheet Functions 5 March 30th 07 08:12 PM
Select and Insert one sheet from a multisheet excel template Alex at Europlan Excel Discussion (Misc queries) 0 November 22nd 05 03:51 PM
Insert Rows in Balance Sheet Template Teacher_Becky New Users to Excel 2 November 21st 05 02:15 AM
Inserting a row in sheet A should Insert a row in sheet B, removing a row in Sheet A should remove the corresponding row in sheet B Hannes Heckner Excel Programming 1 March 5th 04 09:10 AM


All times are GMT +1. The time now is 11:50 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"