Results 1 to 3 of 3

VBA code Copy data into one file

Threaded View

  1. #1
    Registered User
    Join Date
    11-05-2008
    Location
    Netherlands
    Posts
    11

    VBA code Copy data into one file

    Hello all

    for a long time i tried to figure out how to make the right vba code for my problem. Found some examples already but can't succeed to adjust them properly. I lack the knowledge sadly. Maby someone can help me a bit further.

    In short: i have about 2000 files made in excel. They are all the same. Now i need to copy name of file in A2, from sheet "Algemeen" D3 in B2, D6 in B3. If there is no data in them i need a warning like *empty , (but thats not stricktly necessary, I also need more data from othersheets but i hope i can figure out that myself later). I found an example code from rondebruin. It works when using his examplefile but when putting into another folder i get a error. Next is how can i "range" the cells; maby i understand "ranging" wrong? SourceRng:="D3,D6", doesnt work. If this code is not suitable can someone send me a link where i can find a better one?

    many thanks already.

    greetings PeterDV
    --------------
    Sub RDB_Merge_Data()
        Dim myFiles As Variant
        Dim myCountOfFiles As Long
    
        myCountOfFiles = Get_File_Names( _
                         MyPath:="H:\My documents\_doc_bureaublad\Peter\macro maken cellen", _
                         Subfolders:=False, _
                         ExtStr:="*.xls", _
                         myReturnedFiles:=myFiles)
    
        If myCountOfFiles = 0 Then
            MsgBox "No files that match the ExtStr in this folder"
            Exit Sub
        End If
    
        Get_Data _
                FileNameInA:=True, _
                PasteAsValues:=True, _
                SourceShName:="Algemeen", _
                SourceShIndex:=1, _
                SourceRng:="D3", _
                StartCell:="", _
                myReturnedFiles:=myFiles
    
    End Sub
    Last edited by PeterDV; 11-05-2008 at 11:23 AM. Reason: add code tags

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