Eli pitäis saada kansiosta luettuun kaikki esim. 4356 tiedostoa jotka on nimetty numerolla numerojärjestyksessä. Näistä suurimman arvo täytyis saada soluun eli esim. 4356.xlsm ja sitten vielä tuo pääte pois niin että jää vaan 4356.
Käytössä excel 2007 ja totesin pari päivää ongelmaan ratkaisua etsiessäni että 2003 komennot ei toimi eli Application.FileSearch
Tälläisellä sain suurimmalla numerolla alkavan tulemaan näkyviin
Dim sPath As String
Dim sfil As String
Dim strName As String
sPath = "Y:\Työaikakortit\Työkortit\"
sfil = Dir(sPath & "\" & "*.xlsm")
ChDir sPath
Do While sfil ""
strName = sfil
Dim tietue As Integer
tietue = Len(strName)
Dim lukema As String
lukema = strName
Range("K2") = lukema
Range("K3") = tietue
sfil = Dir
Loop
Käytössä excel 2007 ja totesin pari päivää ongelmaan ratkaisua etsiessäni että 2003 komennot ei toimi eli Application.FileSearch
Tälläisellä sain suurimmalla numerolla alkavan tulemaan näkyviin
Dim sPath As String
Dim sfil As String
Dim strName As String
sPath = "Y:\Työaikakortit\Työkortit\"
sfil = Dir(sPath & "\" & "*.xlsm")
ChDir sPath
Do While sfil ""
strName = sfil
Dim tietue As Integer
tietue = Len(strName)
Dim lukema As String
lukema = strName
Range("K2") = lukema
Range("K3") = tietue
sfil = Dir
Loop
Vastaukset 1
Vanhimmat
Ihan vahingossa se onnistu.. piti ottaa solut mukaan leikkiin.. Saattoipa siihen jäädä jotain turhaakin mutta kun toimi tuolla niin enpä ruennut enää turhia karsimaan..
Application.ScreenUpdating = False
Dim sPath As String
Dim sfil As String
Dim strName As String
Dim laske As Integer
Dim o As Integer
Dim u As Integer
o = 0
For i = 0 To 3000
sPath = "Y:\Työaikakortit\Työkortit\"
sfil = Dir(sPath & "\" & i & ".xlsm")
ChDir sPath
Do While sfil ""
strName = sfil
Dim tietue As Integer
tietue = Len(strName)
Dim lukema As String * 2
lukema = strName
Dim lukema2 As Integer
lukema2 = Range("K2").Value
Range("K2") = lukema
Range("K3") = tietue
sfil = Dir
o = o 1
Range("K4") = o
Range("D2") = o
Loop
If i > o Then
u = u 1
End If
If u > 3 Then
i = 3000
End If
Next
Application.ScreenUpdating = True