Results 1 to 14 of 14

Thread: [RESOLVED] Moving worksheets from one app to another

Threaded View

  1. #3
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Moving worksheets from one app to another

    Do you Open these 'applications' (Excel Workbooks?) in your code? If so, that makes it easier ... but in any case, it is not particularly difficult.
    Code:
    Option Explicit
    Sub Macro1()
    Dim aBook As Workbook    'Loop Index
    Dim SrcBook As Workbook  'Source Workbook Handle
    Dim DstBook As Workbook  'Destination Workbook Handle
    Dim i As Integer         'Book Counter = 2 if 1 source book and 1 destination book
    
    i = 0
    For Each aBook In Application.Workbooks
        MsgBox aBook.Name  '<< TEST
        If InStr(1, aBook.Name, "CER") Then SrcBook = aBook: i = i + 1
        If InStr(1, aBook.Name, "MAC") Then DstBook = aBook: i = i + 1
    Next
    If i <> 2 Then MsgBox "We do NOT have proper Source and Destination Workbooks!": Exit Sub
    'Do your sheet move here ... you can get this from recording a Macro
    'SrcBook.Sheets(sheetname_stringvar) is how you reference the source sheet to be moved
    '  or  SrcBook.Sheets("MC") ...
    End Sub
    Good Luck and Good Learning! I'll keep an eye on this thread.
    Last edited by Webtest; Aug 30th, 2005 at 10:22 AM. Reason: added explicit reference to sheetname "MC"
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width