+ Reply to Thread
Results 1 to 5 of 5

refer one excel from another excel with partial name

Hybrid View

  1. #1
    Registered User
    Join Date
    09-20-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    10

    refer one excel from another excel with partial name

    Hi,
    Is it possible to refer one excel from another excel with partial name?

    Below is my macro(working fine), in this example I am refering "September2_MonthData.xls"(excel will be open when refering) excel document from another excel "consolidated Data.xls".

    Now the question is it possible to refer "September2_MonthData.xls" excel doc like any excel open(active) document ending with "%%%%%_MonthData.xls" from another excel "consolidated Data.xls".

    Because for every week, there will be one excel document, so instead of changing name of excel doc name in macro everyweek, is it possible to refer like "%%%%%_MonthData.xls" from another excel "consolidated Data.xls"?

    ------------
    Dim i, j As Integer
    Dim BETA As Worksheet
    
    Sub Data()
    Set BETA = Workbooks("September2_MonthData.xls").Worksheets("BETA")
    BETA.Activate
    i = 2
    j = 2
    Do While BETA.Cells(j, 1) <> ""
    ALPHA.Cells(i, 3).Value = BETA.Cells(j, 1).Value 
    ..........
    ..........
    j = j + 1
    i = i + 1
    Loop
    End Sub
    ===============================
    Last edited by syprakash; 10-03-2010 at 03:05 PM. Reason: Using code tags around code

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: refer one excel from another excel with partial name

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  3. #3
    Registered User
    Join Date
    09-20-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: refer one excel from another excel with partial name

    Hi,
    Is it possible to refer one excel from another excel with partial name?

    Below is my macro(working fine), in this example I am refering "September2_MonthData.xls"(excel will be open when refering) excel document from another excel "consolidated Data.xls".

    Now the question is it possible to refer "September2_MonthData.xls" excel doc like any excel open(active) document ending with "%%%%%_MonthData.xls" from another excel "consolidated Data.xls".

    Because for every week, there will be one excel document, so instead of changing name of excel doc name in macro everyweek, is it possible to refer like "%%%%%_MonthData.xls" from another excel "consolidated Data.xls"?

    Dim i, j As Integer
    Dim BETA As Worksheet
    
    Sub Data()
    Set BETA = Workbooks("September2_MonthData.xls").Worksheets("BETA")
    BETA.Activate
    i = 2
    j = 2
    Do While BETA.Cells(j, 1) <> ""
    ALPHA.Cells(i, 3).Value = BETA.Cells(j, 1).Value 
    ..........
    ..........
    j = j + 1
    i = i + 1
    Loop
    End Sub

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: refer one excel from another excel with partial name

    Sub Data()
        Dim wkb         As Workbook
    
        Set BETA = Nothing
        For Each wkb In Workbooks
            If wkb.Name Like "*_MonthData.xl*" Then
                Set BETA = wkb.Worksheets("BETA")
                Exit For
            End If
        Next wkb
        
        If BETA Is Nothing Then
            MsgBox "Oops"
            Exit Sub
        End If
    
        BETA.Activate
        
        ' ...
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    09-20-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    10

    Smile [SOLVED] Re: refer one excel from another excel with partial name

    Dear Shg,
    This works perfectly , thanks a lot

    Regards,
    Prakash

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1