Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Worksheet Name Variable Problem

I'm trying to set the names of two worksheets. I have a macro in the first
one that opens the second worksheet, and writes data to several cells in the
2nd worksheet.
I need to have the 2nd worksheet become the active sheet, and close the
first worksheet before I proceed. I'm trying to name the workbooks so I can
activate either one, but what I really need to do is have the 2nd worksheet
continue calling macros after the 1st sheet has been closed.
The code I'm using is below.

Sub timeout()

Dim wbSource As Workbook, wbZip As Workbook
Dim wbName As String
wbName = Range("A2").Value
wbZip = ActiveWorkbook
wbSource = wbName

Windows(wbName).Activate
ActiveWorkbook.Close SaveChanges:=True

Windows(wbZip).Activate
Worksheets(2).Activate
Range("B1").Select

Call ZipTheFile

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Worksheet Name Variable Problem

After I read this it didn't make sense. The worksheets are already named. I'm
trying to capture those names in variables. But again, what I'm really trying
to do is open a 2nd workbook (always the same name), call a macro in the 2nd
workbook from the 1st workbook, make the 2nd workbook active, close the 1st
workbook (without changing the name, although the names of the 1st workbook
will always be different) and then continue running macros in the 2nd
workbook after the 1st is closed. I'm also writing data from workbook 1 to 2
before closeing 1. That make's better sense now!

David

"David" wrote:

I'm trying to set the names of two worksheets. I have a macro in the first
one that opens the second worksheet, and writes data to several cells in the
2nd worksheet.
I need to have the 2nd worksheet become the active sheet, and close the
first worksheet before I proceed. I'm trying to name the workbooks so I can
activate either one, but what I really need to do is have the 2nd worksheet
continue calling macros after the 1st sheet has been closed.
The code I'm using is below.

Sub timeout()

Dim wbSource As Workbook, wbZip As Workbook
Dim wbName As String
wbName = Range("A2").Value
wbZip = ActiveWorkbook
wbSource = wbName

Windows(wbName).Activate
ActiveWorkbook.Close SaveChanges:=True

Windows(wbZip).Activate
Worksheets(2).Activate
Range("B1").Select

Call ZipTheFile

End Sub

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
problem with setting the worksheet variable ws Janis Excel Discussion (Misc queries) 4 January 17th 08 02:21 PM
Link variable data from one worksheet to another worksheet? T MAT New Users to Excel 3 November 27th 07 06:46 AM
Variable worksheet name (tab) linked to cell in same worksheet azbob Excel Worksheet Functions 6 January 9th 07 06:27 PM
Looking up a variable in one worksheet and copying information from another column to another worksheet?? Brad Torken Excel Discussion (Misc queries) 2 December 10th 06 06:02 AM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


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