Thread: Sub assistance
View Single Post
  #22   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Sub assistance

I've never used the bloomberg stuff, so this is just a guess.

Try adding these two lines after the .copy line:

doevents
application.calculate

(maybe the doevents will mean you won't need the .calculate--you'll find out
soon!)

If that doesn't work, then try:

Set wks = ActiveSheet 'just copied version of live

'doevents
'application.calculate

With wks
.cells.Replace what:="=", replacement:="=", _
lookat:=xlPart, searchorder:=xlByRows, _
MatchCase:=False

....

This replaces the equal sign with equal sign. Hoping that it forces excel to
recalculate all the formulas in the new worksheet.

Since the name is changed to the month and day, there's a good chance that it'll
fail when you're testing.

I'd use something that would make it much harder to fail:

..Name = Format(Now, "yyyymmdd hhmmss")

It would be pretty weird to have the program run at the same second!

Max wrote:

Dave, I hit some problems trying it out live at the office ..

a. The core Sub YourSubRoutineNameHere()
The pasted new sheet (copied from Live) seems to be prematurely? copied as
all of the formulated cells pasted are showing errors such as "#Name", or
"#N/A requesting data". The live formulas involved are Bloomberg formulas,
and the PC is a bloomberg terminal. When I tested it at home the other day,
I used some volatile functions (Rand(),Now()) and it worked fine. What can
be done to force the sub to wait awhile (say, 30 sec) before copying the
sheet, codename: Live, and pasting it? That should suffice to allow all
calcs to complete before the copy/paste proceeds.

b. The timer subs
On 2 testing occasions I was somehow caught in an interminable: "Rename
failed!" loop where answering the msgbox failed to end the sub (it looped to
return yet another "Rename failed!"), and I had to Ctrl-break to stop the
sub.

Grateful for further views, thanks


--

Dave Peterson