Veri Al Dosya Yolu

burhancavus61

Altın Üye
Katılım
13 Mayıs 2005
Mesajlar
761
Excel Vers. ve Dili
2010 Türkçe
Altın Üyelik Bitiş Tarihi
03.11.2024
Aşağıdaki kod ile veri alıyorum. Ama dosya yolunun seçilebilir olmasını nasıl sağlarım. Dosya yolundan txt dosyasını ben seçebilmeliyim.

Kod:
Sub Veriçek()

    Sheets("Veri Al").Select
    ActiveSheet.Unprotect "61"
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range("A2:CC2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range("A2:CC500").Select
'    Selection.QueryTable.Delete
    Selection.ClearContents
    Range("A2").Select

    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;C:\Puantaj\ANTALYA-01.01.2020-31.01.2020-Puantaj.txt", Destination:= _
        Range("$A$2"))

        .Name = "ANTALYA-01.01.2020-31.01.2020-Puantaj_2"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 1252
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
        1, 1, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
    ActiveSheet.Protect "61", DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFiltering:=True

End Sub
 
Katılım
31 Aralık 2014
Mesajlar
1,845
Excel Vers. ve Dili
Excel 2010
Merhaba
Kodlarda; aşağıdaki kısma kadar değişip deneyiniz
Kod:
Sub Veriçek()

    Sheets("Veri Al").Select
    ActiveSheet.Unprotect "61"
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range("A2:CC2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range("A2:CC500").Select
'    Selection.QueryTable.Delete
    Selection.ClearContents
    Range("A2").Select
    ChDrive "C"
ChDir "C:\Puantaj\"
fn = Application.GetOpenFilename("Text Dosyaları (*.txt), *.txt", , , False)
If fn = False Then Exit Sub
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & fn, Destination:= _
        Range("$A$2"))
        .Name = Split(Dir(fn), ".txt")(0) & "_2"
        .FieldNames = True
        
        '................
        '......diğer kodlar
        '......
        
        End sub'
 

burhancavus61

Altın Üye
Katılım
13 Mayıs 2005
Mesajlar
761
Excel Vers. ve Dili
2010 Türkçe
Altın Üyelik Bitiş Tarihi
03.11.2024
Elinize sağlık çok teşekkür ederim.
 
Üst