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: 38
Default Selecting Sheet1 by index rather than sheet name

I have a program to automatically transfer data from an older version to an
updated file The Macro runs from the new file. Right now I have the user
enter the old filename and first sheet name by input boxes. This works well
but I would like VBA to detect the old file that would be already open and
put the name into a variable. The transfer always starts from Sheet1 of the
old file no matter what the name of the sheet has been changed to.

This works but not what I want:
OLDFILENAME = Inputbox("ENTER OLD FILE NAME")
FIRSTSHEETNAME = Inputbox("ENTER NAME OF FIRST SHEET IN OLD FILE")
Windows(OLDFILENAME).Activate
Sheets("FIRSTSHEETNAME").Select

This is what I would like

<macro to find other open workbook
OLDFILENAME = <detected workbook
Windows(OLDFILENAME).Activate
Sheet1.Select <-- This gives an error msg

or

Windows(OLDFILENAME).Activate
Sheet1.Activate <-- This activates Sheet1
of the new workbook
that the macro runs in

Thank you in advance
 
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
copying 'sheet1'!A1 to sheet 2, I want to get 'sheet2'A1, not 'she Dany Excel Discussion (Misc queries) 5 April 21st 07 11:14 PM
Selecting chartobject without index no. Jaylin Charts and Charting in Excel 4 August 24th 06 04:31 PM
transfer data from sheet1 to sheet 2 joe311 Excel Worksheet Functions 5 April 13th 06 01:49 AM
Selecting a cell from an index Canuck[_2_] Excel Programming 1 May 16th 04 09:07 PM
selecting a cell in sheet1 paul mueller Excel Programming 1 November 18th 03 09:15 PM


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