Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting a worksheet from a macro in a different workbook

I have updated a complicated workbook and its macros. I want to provide a
macro that transfers the data from the old workbooks to the new version. The
old files may have 100 or more worksheets. That is not where I'm having
trouble. I have the transfer part working well but I want to make the process
simple for the user. The program switches back and forth between the old and
new creating a new worksheet in the new workbook and then transfers the data.

Right now the coding I have requires the user to enter the name of the old
file which would already be open. I would like Excel to search for the other
open file automatically.
After that I want the program to always select Sheet1 of the old file to
start. I thought this would be simple but I get an error when the program
gets to that line

sub XFERDATA

NEWFILE = ActiveWorkbook.Name
OLDFILE = InputBox("Enter old file name including .xls extension")
OLDSHEET = InputBox("ENTER NAME OF FIRST SHEET IN OLD WSWD")
Windows(OLDFILE).Activate <-- activates old file
Worksheets(OLDSHEET).Select <-- selects the sheet by name on old file

The above works ok but the program always starts from Sheet1 (by index) and
I would like it to eliminate the InputBoxes and to initially work like this:

< detect other open workbook from new one
OLDFILE = <name of other open workbook
Window(OLDFILE).Activate
Sheet1.Select <-- this does not work even when OLDFILE
is entered
thru the input box. It gets
an object error msg. I
have to use whatever the
sheet name changed to.
OLDSH = ActiveSheet.Name <-- then after Sheet1 is selected from the old
file
the actual name of the
sheet would be saved

Thanks for your help. This site has been great for solving problems. I think
there should be a simple solution but I sure can't find it.


Windows(NEWFILE).Activate
OLDFILE = Range("P4")

' OLDSH = Range("P5")
PREVSH = ""
SH1 = ActiveSheet.Name

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
Macro add worksheet to workbook automatically Davin Excel Discussion (Misc queries) 0 February 17th 06 05:36 PM
Selecting a worksheet in a workbook Lazer[_8_] Excel Programming 1 August 24th 04 08:52 PM
worksheet to workbook macro Ron de Bruin Excel Programming 6 June 9th 04 08:55 PM
selecting workbook/worksheet from browse button monika Excel Programming 9 February 8th 04 09:40 AM
Macro for worksheet to workbook Brian Excel Programming 2 December 23rd 03 08:00 PM


All times are GMT +1. The time now is 01:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"