Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Workbooks with variable names


Hi,

I'm writing a macro to copy and paste value froms from 2 workbooks int
a third workbook. The filenames will vary according to month.
Let's say my files a "Summary Oct04.xls", "Mgt Oct04.xls" and "Boar
Oct04.xls". Obviously for November the filenames will be different.

How can I define these to the macro will copy from the relevan
worksheet to the correct workbook, regardless of the filename.

Any help would be appreciated.

Thanks,



--
bpmcco
-----------------------------------------------------------------------
bpmccoy's Profile: http://www.excelforum.com/member.php...fo&userid=1671
View this thread: http://www.excelforum.com/showthread.php?threadid=31922

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Workbooks with variable names

General form (once you have copied the necessary cells) is as below
Workbooks(DestinationBook).Sheets(DestinationSheet ).Range(DestinationRange).PasteSpecial

In VBA you will need to set or calculate DestinationBook, DestinationSheet,
and DestinationRange - to extract the month from the end of your file name to
select the matching DestinationBook you can do this:

Dim FileSuffix as String
FileSuffix = ActiveWorkbook.Name
' Following line takes just from final space forward - i.e., 'MMMYY.xls'
FileSuffix = Right(FileSuffix, Len(FileSuffix)-InStrRev(FileSuffix," "))
DestinationBook = "Board " & FileSuffix ' If you want to copy to the Board
file

"bpmccoy" wrote:


Hi,

I'm writing a macro to copy and paste value froms from 2 workbooks into
a third workbook. The filenames will vary according to month.
Let's say my files a "Summary Oct04.xls", "Mgt Oct04.xls" and "Board
Oct04.xls". Obviously for November the filenames will be different.

How can I define these to the macro will copy from the relevant
worksheet to the correct workbook, regardless of the filename.

Any help would be appreciated.

Thanks,

B


--
bpmccoy
------------------------------------------------------------------------
bpmccoy's Profile: http://www.excelforum.com/member.php...o&userid=16715
View this thread: http://www.excelforum.com/showthread...hreadid=319220


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Workbooks with variable names


"bpmccoy" wrote in message
...

Hi,

I'm writing a macro to copy and paste value froms from 2 workbooks into
a third workbook. The filenames will vary according to month.
Let's say my files a "Summary Oct04.xls", "Mgt Oct04.xls" and "Board
Oct04.xls". Obviously for November the filenames will be different.

How can I define these to the macro will copy from the relevant
worksheet to the correct workbook, regardless of the filename.


I assume Summary is the target for Mgt & Board. I also assume the latter
part of the filename will always be 5 characters (MMMYY).

pastefilename = "Summary " + Mid(ActiveWorkbook.Name,
Len(ActiveWorkbook.Name) - 8, 5) + ".xls"

Incorporate pastefilename into the paste part of your macro.

Ian


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
Combining workbooks with some variable field names Bob Dobalina Excel Discussion (Misc queries) 8 May 17th 05 09:48 PM
Use variable across workbooks Steph[_3_] Excel Programming 2 September 29th 04 01:12 PM
Variable names in SQL Hall Excel Programming 2 May 28th 04 11:39 PM
Combining variable names Bernie Gaile Excel Programming 2 December 28th 03 09:24 PM
Variable Control Names Garry Jones Excel Programming 4 October 3rd 03 10:45 PM


All times are GMT +1. The time now is 01:16 PM.

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"