+ Reply to Thread
Results 1 to 6 of 6

Populate array dynamimically from a different Excel workbook

Hybrid View

Bruce Tjosvold Populate array dynamimically... 06-25-2012, 04:51 PM
gmk Re: Populate array... 06-25-2012, 07:18 PM
Bruce Tjosvold Re: Populate array... 06-25-2012, 07:45 PM
gmk Re: Populate array... 06-25-2012, 08:48 PM
Bruce Tjosvold Re: Populate array... 06-27-2012, 03:34 PM
gmk Re: Populate array... 06-27-2012, 05:46 PM
  1. #1
    Forum Contributor
    Join Date
    04-12-2012
    Location
    MD, England
    MS-Off Ver
    Excel 2003
    Posts
    142

    Re: Populate array dynamimically from a different Excel workbook

    Bruce Tjosvold

    Use this construction. Change the sheet numbers where I have commented. I have tested the code using my own file paths.

    Sub TestThis()
    
        Dim LR As Long
        Dim Tester_IDs As Variant
        Dim user_name As String
        Dim nMatch As Long
    
        user_name = "ANDERSD4"
    
        Workbooks.Open ("\\spnas2\spdept\dept\SAP_TECH\S:\Upload Master Templates\JEMASTER\Bruce_test\Tester_IDs.xlsx")
        
        LR = ActiveWorkbook.Sheets(2).Range("A" & Rows.Count).End(xlUp).Row    ''' change the Sheets() num to suit
        Set Tester_IDs = ActiveWorkbook.Sheets(2).Range("A1:A" & LR)    ''' change the Sheets() num to suit
    
        On Error Resume Next    ''' allow for not found
        nMatch = WorksheetFunction.Match(user_name, Tester_IDs, 0) + 1
        If nMatch > 0 Then
            MsgBox "Yes, it is there"
        Else
            MsgBox "No, not found"
        End If
        On Error GoTo 0
    
        Workbooks("Tester_IDs.xlsx").Close False   ''' remember to close the master template at some stage
        Set Tester_IDs = Nothing    ''' free up memory
    
    End Sub

  2. #2
    Registered User
    Join Date
    06-08-2012
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Populate array dynamimically from a different Excel workbook

    gmk,

    Thanks for the help. I'm an experienced SAP ABAP developer. But this VBA is brand new to me, as is any Windows programming.

    I have been tasked with modifying a very complex VBA application to replace numerous HARD CODED values with parameters that will be in several different EXCEL file.

    You have started my on my way. I appreciate the help.

    Bruce

  3. #3
    Forum Contributor
    Join Date
    04-12-2012
    Location
    MD, England
    MS-Off Ver
    Excel 2003
    Posts
    142

    Re: Populate array dynamimically from a different Excel workbook

    Bruce

    Pleased to be of assistance.

    Please mark the the thread as solved if it is the answer you require and if you feel it is warrented then add to my reputation by clicking on the star at the bottom of my reply.

    gmk

+ 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