How do I get only the folder names to be listed?

secoo140

Board Regular
Joined
Oct 12, 2013
Messages
85
Office Version
  1. 2010
Platform
  1. Windows
Hello,
I am creating sequential files.
I am using the sorting function of files to find out how long I have been left.
I got the code ready, it became working with a few modifications.
But it makes my computer very slow because it lists all the files.

I think it will speed up if it just sorts the folder names.
How do you think I can limit this code?
thanks

VBA Code:
Dim sayi
Dim sat
Sub klasör_dosya1()
Dim P1 As Worksheet
Dim WB As Workbook
Set WB = ThisWorkbook
kaynak = "S:\TRT\Prostat_Kanseri_PSMA"

Set P1 = WB.Worksheets("P1")
P1.Select

Cells.ClearContents
Cells.Hyperlinks.Delete
Cells.Font.ColorIndex = 0

deg1 = Split(kaynak, "\")
Cells(1, 1).Value = deg1(UBound(deg1))
sat = 1
If UBound(deg1) > 0 Then
sayi = UBound(deg1)
End If
Liste (kaynak)
Call VBAColumn1
Call findlastrow

End Sub
Private Sub Liste(Yol As String)
Dim fL As Object, fs As Object, f As Object, j As Long, n As Long
Set fL = CreateObject("Scripting.FileSystemObject")

deg1 = Split(Yol, "\")
If UBound(deg1) > 0 Then
sut = UBound(deg1) + 1 - sayi
End If


Cells(sat, sut).Hyperlinks.Add Anchor:=Cells(sat, sut), Address:=Yol, SubAddress:="" & firstAddress, TextToDisplay:=fL.GetBaseName(Yol)
fL.GetBaseName (Yol)

sut = sut + 1

If fL.GetFolder(Yol).Files.count > 0 Then
sat = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For Each Dosya In fL.GetFolder(Yol).Files
Cells(sat, sut).Hyperlinks.Add Anchor:=Cells(sat, sut), Address:=Dosya, SubAddress:="" & firstAddress, TextToDisplay:=fL.GetBaseName(Dosya.Name)
sut = sut + 1
Next
End If

On Error GoTo sonraki
For Each f In fL.GetFolder(Yol).Subfolders
Liste (f.Path)
sat = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
sonraki:
Next

End Sub

Sub VBAColumn1()

Range("D:D").Insert
    
With Range("D1:D" & Cells(Rows.count, "C").End(xlUp).Row)
        .Formula = "=Left(C1, 4)"
End With


End Sub

Private Sub findlastrow()
Range("d1").End(xlDown).Copy
Range("A2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
With Range("a2")
    .NumberFormat = "0000"
    .Value = .Value
End With
End Sub
 

Attachments

  • exc.jpg
    exc.jpg
    234.3 KB · Views: 19

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,415
Messages
6,119,375
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top