Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default selecting sheets of the same name between two workbooks

I'm trying to push some data from one workbook to another. Both
workbooks have sheets of the same name, so I was trying to use a
variable (mySheet), which is set in one workbook, then another workbook
is activated. Now I want to ensure that I'm on the same sheet as I was
in the first workbook (they are all week ending sheets, so the names
are dates). If the same sheet is already active in the second
workbook, the code works fine, if it's not, I get a subscript out of
range on the Sheets(mySheet).Activate line. Any ideas? Thanks in
advance for any help.

Sub Assign()
Call TurnOff
mySheet = ActiveSheet.Name
myJob = [data!e2].Value
myAgent = [data!e1].Value
myHours = [data!e3].Value
myType = [data!e4].Value
Dim mySheet As String
[c:c].Select
Selection.Find(what:=myJob, after:=ActiveCell, LookIn:= _
xlFormulas, lookat:=xlPart, searchorder:=xlByRows,
searchdirection:= _
xlNext, MatchCase:=False, searchformat:=False).Select
myRow2 = ActiveCell.Row
Range("V" & myRow2).Select
ActiveCell.End(xlToLeft).Activate
myColumn2 = ActiveCell.Column
Cells(myRow2, myColumn2).Offset(0, 1).Activate
ActiveCell.Value = myAgent
Cells(myRow2, myColumn2).Offset(0, 2).Activate
ActiveCell.Value = myHours
Windows("Support By Individual.xls").Activate
If ActiveSheet.Name < mySheet Then Sheets(mySheet).Activate
[a2:a32].Select
Selection.Find(what:=myAgent, after:=ActiveCell, LookIn:= _
xlFormulas, lookat:=xlPart, searchorder:=xlByRows,
searchdirection:= _
xlNext, MatchCase:=False, searchformat:=False).Select
myRow = ActiveCell.Row
If myType = "EF" Then myMove = "6"
If myType = "Ops" Then myMove = "8"
If myType = "KB" Then myMove = "7"
If myType = "Conversions" Then myMove = "10"
If myType = "Processing" Then myMove = "9"
ActiveCell.Offset(0, myMove).Select
If ActiveCell.Value = "" Then
ActiveCell.Value = myHours
Else: CurHours = ActiveCell.Value
TotHours = (CurHours) * 1 + (myHours) * 1
ActiveCell.Value = TotHours
End If
Range("V" & myRow).Select
ActiveCell.End(xlToLeft).Activate
myColumn = ActiveCell.Column
Cells(myRow, myColumn).Offset(0, 1).Activate
ActiveCell.Value = myJob
Windows("support by project.xls").Activate
Call AutoSize
Call TurnOn
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default selecting sheets of the same name between two workbooks

Oh wait, I figured it out, I didn't have the sheet name I was using to
test this the same in both workbooks (one was 4-28-2006 and the other
was 04-28-2006). Any other thoughts on the code would be appreciated
though.

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
Selecting sheets Dr.Schwartz Excel Discussion (Misc queries) 4 July 14th 05 01:49 PM
Selecting Workbooks Darren Excel Programming 4 December 18th 04 01:37 AM
Selecting Workbooks Sohpie Excel Programming 6 October 7th 04 02:04 PM
selecting sheets kevin Excel Programming 4 November 27th 03 11:06 PM
Changing the value in multiple sheets without selecting those sheets herm Excel Programming 3 October 14th 03 03:50 PM


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