Results 1 to 3 of 3

Modify file import macro to skip previously imported files.

Threaded View

dcgrove Modify file import macro to... 08-03-2009, 11:12 AM
ravishankar Re: Modify file import macro... 08-04-2009, 01:31 AM
dcgrove Re: Modify file import macro... 08-04-2009, 04:37 PM
  1. #1
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Modify file import macro to skip previously imported files.

    Hello, the code below imports all the excel files in the folder it is saved in. I use this to create a database containing those files. Is it possible to modify this code to only import the files that is has not previously imported?

    Thanks!

    Sub List()
    Dim z  As Long, e As Long, g As Long
    Dim f As String, h As String
    
    Cells(1, 1) = "=cell(""filename"")"
    Cells(1, 2) = "=left(A1,find(""["",A1)-1)"
    e = 2
    Cells(3, 1).Select
    f = Dir(Cells(1, 2) & "*.xls")
    Do While Len(f) > 0
    ActiveCell.Formula = f
    ActiveCell.Offset(1, 0).Select
    f = Dir()
    Loop
    z = Cells(Rows.Count, 1).End(xlUp).Row
    For e = 3 To z
    For g = 1 To 17
    h = Choose(g, "H6", "A9", "F9", "A12", "F12", "A16", "F14", "A23", "A26", "C28", "D30", "D32", "D34", "A37", "D39", "F36", "F28")
    Cells(2, g + 1) = h
    Cells(1, 3) = "='" & Cells(1, 2) & "[" & Cells(e, 1) & "]Sheet1'!" & h
    Cells(e, g + 1) = Cells(1, 3)
    Next g
    Next e
    
    Call formatall
    Call DeleteRows
    
    MsgBox "PIR import is complete!"
    End Sub
    Attached Files Attached Files

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