CodingAnyone know any VBA (Excel)?

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Queeg 500 (JESUSONEEZ)  
 To:  ALL
40527.1 
I don't know VBA, but I feel that what I want to do should be simple...I've recorded a macro to simply import a TAB delimited text file, and the resulting code is;

code:
Sub Import_Stats_Breakdown()
'
' Import_Stats_Breakdown Macro
'

'
    Sheets("Breakdown Contacts").Select
    Range("A2").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;Seatrade Shared:DATABASE (NEW):Contact Extract - Breakdown", Destination:=Range("A2"))
        .Name = "Contact Extract - Breakdown"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = xlMacintosh
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(2, 2, 2)
        .Refresh BackgroundQuery:=False
        .UseListObject = False
    End With
    Range("A2").Select
End Sub

Now, what I want to be able to do is tell it to import a file based on a filename entered in say, cell C3, so I need to change the 'With...' line to something, and also the '.Name...' line I guess.

Can anyone help? There are some positive thoughts in it for you.


Windows 8 - We hate it in the pants, panties and in the ear
0/0
 Reply   Quote More 

Reply to All    
 

1

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats