LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Workbook.Activate / Window.Activate problem

OK. I give up. Someone smarter than me is going to need to tell me
why I am deleting the worksheet from the wrong workbook. Seems like I
can't figure out how to correctly shift from one to another. The last
statement here gives me a 'subscript out of range' error, and I can't
figure out why.

Code follows:

Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal
Target As Range)
Dim cell As Range
Dim wrksht As Worksheet
Dim SendMail As Outlook.MailItem
Dim i%, ReportPage$, ReportRow%, Subject$, SelectedAddresses$,
ScheduleName$, IndividualName$

If sh.Name Like "####Q#" Then
If Target.Row <= 2 And Cells(Target.Row, Target.Column).Value <
"" Then
If MsgBox("Generate report for " & Range(sh.Name & "!" &
Cells(1, Target.Column).Address).Value & " " & Range(sh.Name & "!" &
Cells(2, Target.Column).Address).Value & "?", vbYesNo) = vbYes Then
ScheduleName$ = Left(ActiveWorkbook.Name,
Len(ActiveWorkbook.Name) - 4)
IndividualName$ = ScheduleName$ & " " & Range(sh.Name & "!"
& Cells(1, Target.Column).Address).Value & " " & Range(sh.Name & "!" &
Cells(2, Target.Column).Address).Value
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=IndividualName$
Workbooks(ScheduleName$ & ".xls").Activate
Sheets(Array(Left(ActiveSheet.Name, 5) & "1",
Left(ActiveSheet.Name, 5) & "2", Left(ActiveSheet.Name, 5) & "3",
Left(ActiveSheet.Name, 5) & "4")).Copy
befo=Workbooks(IndividualName$ & ".xls").Sheets(1)
Workbooks(IndividualName$ & ".xls").Activate
' Windows("CPF Time Off Schedule V2 Mia
Bijaksana.xls").Activate
'Sheets("Sheet1").Delete
Workbooks(ScheduleName$ & ".xls").Activate
Windows(ScheduleName$ & ".xls").Activate
Workbooks(IndividualName$ & ".xls").Activate
Windows(IndividualName$ & ".xls").Activate

 
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
Generic Window Activate Michael Excel Programming 3 March 4th 04 08:42 PM
Activate new window Robert Rosenberg[_2_] Excel Programming 0 December 30th 03 04:46 PM
Activate new window Tom Ogilvy Excel Programming 0 December 30th 03 04:37 PM
Activate Non-Excel Window Through VBA Mark Bigelow Excel Programming 1 September 3rd 03 07:37 PM
How to keep window + form activate together John Brash Excel Programming 1 July 24th 03 10:13 AM


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