Dosya Yolundan Filtreleme

Katılım
11 Nisan 2009
Mesajlar
33
Excel Vers. ve Dili
Excel 2003
ChDrive ("D:\RAPORLAR2019\28\")
Open Application.GetOpenFilename("D:\RAPORLAR2019\, *.txt") For Input As #1

Herkese Merhaba...

Yukarıdaki kod ile dosya yolunu açıyorum.Dosya yolumda Ç harfi ve B harfi ile başlayan txt dosyalarım var.Sadece B harfi ile başlayan dosya seçebilsin istiyorum.(Örnek:B19-01.txt).Ç ile başlayan dosyalarım görünmesin.Nasıl yapılabilir?
 

veyselemre

Özel Üye
Katılım
9 Mart 2005
Mesajlar
3,553
Excel Vers. ve Dili
Pro Plus 2021
Kod:
Sub Test()
    With Application.FileDialog(msoFileDialogOpen)
        .initialFilename = "D:\RAPORLAR2019\28\B*.txt"
        If .Show = -1 Then FileOpen = .SelectedItems(1)
    End With
    If FileOpen <> "" Then MsgBox FileOpen
End Sub
 
Katılım
11 Nisan 2009
Mesajlar
33
Excel Vers. ve Dili
Excel 2003
Kod:
Sub Test()
    With Application.FileDialog(msoFileDialogOpen)
        .initialFilename = "D:\RAPORLAR2019\28\B*.txt"
        If .Show = -1 Then FileOpen = .SelectedItems(1)
    End With
    If FileOpen <> "" Then MsgBox FileOpen
End Sub
Private Sub CommandButton59_Click()

Dim J As Long, k As Long
Close #1


ChDrive ("D:\RAPORLAR2019\28\")
On Error GoTo ErrorHandler


With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "D:\RAPORLAR2019\B*.tst"
If .Show = -1 Then Fileopen = .SelectedItems(1)
End With

J = 3
k = 0
Do While Not EOF(1)
k = k + 1
Line Input #1, TextLine
If k > 0 And k < 343 Then
Cells(J, 2) = Replace(TextLine, """", "")

J = J + 1
End If

Loop
Close #1


Dim rFndCell As Range
Dim strData As String
Dim stFnd As String
Dim fCol As Integer
Dim ws As Worksheet

Set ws = Sheets("Sonuc_Beton")

stFnd = ws.Range("B12").Value

With ws
Set rFndCell = .Range("A:MHF").Find(stFnd, LookIn:=xlValues)
If Not rFndCell Is Nothing Then
fCol = rFndCell.Column
ws.Range("B3:B336").Copy ws.Cells(3, fCol)
Else 'Can't find the item
MsgBox "Bulunamadı"
End If
End With

Exit Sub
ErrorHandler:
MsgBox "RAPOR SEÇMEDİNİZ"
End Sub

Veysel Bey.
İlgili yeri verdiğiniz gibi yaptım .Tabi ben kodun tamamını göndermediğim için sorun çıktı. Kodun EOF satırında hata verdi.Error 52 .Nasıl yapabilirim?
 

veyselemre

Özel Üye
Katılım
9 Mart 2005
Mesajlar
3,553
Excel Vers. ve Dili
Pro Plus 2021
Kod:
    With Application.FileDialog(msoFileDialogOpen)
        .InitialFileName = "E:\TEST\*Kopya*.txt"
        If .Show = -1 Then fileOpen = .SelectedItems(1)
    End With

    Open fileOpen For Input As #1 'Bu kısmı eklemeyi unuttunuz sanırım.
Dosyayı açtınız mı acaba ?
 
Katılım
11 Nisan 2009
Mesajlar
33
Excel Vers. ve Dili
Excel 2003
Kod:
    With Application.FileDialog(msoFileDialogOpen)
        .InitialFileName = "E:\TEST\*Kopya*.txt"
        If .Show = -1 Then fileOpen = .SelectedItems(1)
    End With

    Open fileOpen For Input As #1 'Bu kısmı eklemeyi unuttunuz sanırım.
Dosyayı açtınız mı acaba ?
Aynen ekledim.Teşekkür ederim.Sağolun
 
Üst