View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Help with macro opening 2nd sheet

Ctually, looking at my code again,I just replicated the problem you had. I
should have used
Sub OpenOld()
Dim oWb As Workbook

ChDir "C:\My Documents\steves stuff\journal"
Set oWb = ActiveWorkbook
Workbooks.Open(Filename:= _
"C:\My Documents\steves stuff\Journal\Old-Combined.xls")
Windows("CurrentMonth.xls").Activate

' OK Now lets close and save the current diary

' First we need to go back to the data worksheet
' in the current diary as we are currently in the macro worksheet

Sheets("Sheet1").Select

' Now lets save and close the workbook

ActiveWorkbook.Save
ActiveWorkbook.Close

' Now lets go to the 1st real cell in the old historical work sheet

oWb.Activate
Sheets("X Days Ago").Select
Application.Goto Reference:="AdjLookBack"
Range("A5").Select

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steve Lowe" wrote in message
...
Hi Bob -

Sorted it by moving the code :-

Sheets("X Days Ago").Select
Application.Goto Reference:="AdjLookBack"
Range("A5").Select

To immediately after to called sheet is opened - thanks for your help

Regards

Steve.




On Mon, 02 May 2005 13:09:09 +0100 Steve Lowe wrote:

Thanks Bob, however after opening the old-combined sheet the X Days
ago worksheet is still not being made the active sheet - thanks for
the attempt though.

On Mon, 2 May 2005 11:57:11 +0100 "Bob Phillips"
wrote:

Steve,

Try this

Sub OpenOld()
Dim oWb As Workbook

ChDir "C:\My Documents\steves stuff\journal"
Set oWb = Workbooks.Open(Filename:= _
"C:\My Documents\steves stuff\Journal\Old-Combined.xls")
Windows("CurrentMonth.xls").Activate

' OK Now lets close and save the current diary

' First we need to go back to the data worksheet
' in the current diary as we are currently in the macro worksheet

Sheets("Sheet1").Select

' Now lets save and close the workbook

ActiveWorkbook.Save
ActiveWorkbook.Close

' Now lets go to the 1st real cell in the old historical work sheet

oWb.Activate
Sheets("X Days Ago").Select
Application.Goto Reference:="AdjLookBack"
Range("A5").Select

End Sub


- Steve Lowe
- E-Mail :
- Before Replying Remove .NO.SPAM
- UK Resident although my e-mail address is usa.net


- Steve Lowe
- E-Mail :

- Before Replying Remove .NO.SPAM
- UK Resident although my e-mail address is usa.net