Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Calling a different worksheet???

Hi

I've pulled together some code that will save my spreadsheet into htm
format, and update a =now() field. In addition to that code I have some timer
codes which fire off the =now update, and the htm save.

My problem is, if I am working on another spreadsheet, it places the update
into what I'm working on - rather than the "right" file. I've tried telling
it to go to a named workbook & spreadsheet, but the problem is that the code
flicks to that file, and takes me away from the one I was working on. Very
frustrating.

The update to the now field is meant to happen every 5 minutes.

Is there a way to modify the update code so that I can work uninhibited on
other workbooks?

Cheers, Ty


Sub Every5()

Application.OnTime Now + TimeValue("00:05:00"), "SaveMe"

End Sub


Sub SaveMe()

Call UpdateMe

Dim fRange As Range
Sheets("sheet1").Activate
Application.ScreenUpdating = False
Set fRange = Range(Range("a1"), _
Range("a1").End(xlDown).End(xlToRight))
Workbooks.Open Filename:="d:\data\sc\statuses.xls"
Windows("support centre.xls").Activate
fRange.Copy
Windows("statuses.xls").Activate
ActiveSheet.Paste
Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="d:\data\sc\statuses.htm",
FileFormat:=xlHtml, _
CreateBackup:=False
ActiveWorkbook.Close savechanges:=False

End Sub


Sub UpdateMe()

'The purpose of this code is to update the date and time
'in an appropriate format.

'This updates G24
Application.Goto reference:="R24C7"
ActiveCell.FormulaR1C1 = "=now()"
Selection.NumberFormat = "dd mmmm yyyy, h:mm AM/PM"

'Go to description box
Application.Goto reference:="R5C3"

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default Calling a different worksheet???

Tywardreath:

try,

Sub SaveMe()
Call UpdateMe
Dim fRange As Range
Dim wbk As Workbook
Sheets("sheet1").Activate
Application.ScreenUpdating = False
Set fRange = Range(Range("a1"), _
Range("a1").End(xlDown).End(xlToRight))
Set wbk = Workbooks.Open(Filename:="d:\data\sc\statuses.xls" )
fRange.Copy wbk.Worksheets("Sheet1").Cells
Application.DisplayAlerts = False
wbk.SaveAs Filename:="d:d:\data\sc\statuses.htm", FileFormat:=xlHtml, _
CreateBackup:=False
wbk.Close savechanges:=False
Application.DisplayAlerts = True
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Tywardreath" wrote:

Hi

I've pulled together some code that will save my spreadsheet into htm
format, and update a =now() field. In addition to that code I have some timer
codes which fire off the =now update, and the htm save.

My problem is, if I am working on another spreadsheet, it places the update
into what I'm working on - rather than the "right" file. I've tried telling
it to go to a named workbook & spreadsheet, but the problem is that the code
flicks to that file, and takes me away from the one I was working on. Very
frustrating.

The update to the now field is meant to happen every 5 minutes.

Is there a way to modify the update code so that I can work uninhibited on
other workbooks?

Cheers, Ty


Sub Every5()

Application.OnTime Now + TimeValue("00:05:00"), "SaveMe"

End Sub


Sub SaveMe()

Call UpdateMe

Dim fRange As Range
Sheets("sheet1").Activate
Application.ScreenUpdating = False
Set fRange = Range(Range("a1"), _
Range("a1").End(xlDown).End(xlToRight))
Workbooks.Open Filename:="d:\data\sc\statuses.xls"
Windows("support centre.xls").Activate
fRange.Copy
Windows("statuses.xls").Activate
ActiveSheet.Paste
Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="d:\data\sc\statuses.htm",
FileFormat:=xlHtml, _
CreateBackup:=False
ActiveWorkbook.Close savechanges:=False

End Sub


Sub UpdateMe()

'The purpose of this code is to update the date and time
'in an appropriate format.

'This updates G24
Application.Goto reference:="R24C7"
ActiveCell.FormulaR1C1 = "=now()"
Selection.NumberFormat = "dd mmmm yyyy, h:mm AM/PM"

'Go to description box
Application.Goto reference:="R5C3"

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Calling a different worksheet???

Unfortunately the update (to =now()) occurred into the spreadsheet I was
working on (not the file that it should update in).

On the positive side, it did not flick back to the spreadsheet with the
original code.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling a different worksheet???


I think your present code for UpdateMe refers to the activeworkbook
activesheet (which is excel default). You need to make the referenc
clear in this sub. :

--
lotu
-----------------------------------------------------------------------
lotus's Profile: http://www.excelforum.com/member.php...fo&userid=2375
View this thread: http://www.excelforum.com/showthread.php?threadid=49326

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
CALLING MACROS FROM A NEW WORKSHEET NSNR Excel Discussion (Misc queries) 4 February 1st 08 07:10 AM
calling macros from worksheet to another NSNR Excel Discussion (Misc queries) 3 October 27th 07 01:49 PM
calling up information from a different worksheet. Jay Adams Excel Worksheet Functions 0 October 8th 06 09:33 AM
Calling workbook and worksheet Anders Excel Programming 1 December 4th 05 04:42 PM
Calling a macro in another worksheet Tolga[_2_] Excel Programming 2 August 5th 04 07:03 PM


All times are GMT +1. The time now is 07:31 AM.

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"