ich suche einen Befehlt der meinen Dateinamen um i+1 erhöht.
sobald ich i+1 in den datei namen eingebe, findet er ja nicht mehr diese Datei.
Kann mir jemand verraten, wie ich das machen müsste ?
Liebe Grüße
Option Explicit
Sub pourya()
Dim strFileName As String, strTemp As String, strCheck As String, strPath As String
Dim lngIndex As Long
strPath = "D:\Forum"
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
strTemp = "DeinDateiname ohne Zähler"
Do
lngIndex = lngIndex + 1
strFileName = strPath & strTemp & Format(lngIndex, "_000") & ".xlsm"
strCheck = Dir(strFileName, vbNormal)
Loop While strCheck <> ""
ThisWorkbook.SaveAs strFileName, 52
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0
Sub pourya2()
Dim strFileName As String, strPath As String, strTemp As String
Dim i As Long
strPath = "D:\Forum"
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
Do
i = i + 1
strTemp = Dir(strPath & "KW " & Format(i, "00") & " ppm Auswertung.xlsx", vbNormal)
If strTemp <> "" Then
strFileName = strPath & "[" & strTemp & "]"
Cells(3 + i, 3).FormulaR1C1 = _
"=('" & strFileName & "Z1 Bau 15'!R17C2+'" & strFileName & "Z2 Bau 5'!R17C5+'" & _
strFileName & "Z2 Bau 5'!R17C2+'" & strFileName & "Z2 Bau 5'!R17C5+'" & _
strFileName & "Z2 Bau 5'!R17C8+'" & strFileName & "Z2 Bau 5'!R29C2)/('" & _
strFileName & "Z1 Bau 15'!R12C2+'" & strFileName & "Z1 Bau 15'!R12C5+'" & _
strFileName & "Z2 Bau 5'!R12C2+'" & strFileName & "Z2 Bau 5'!R12C5+'" & _
strFileName & "Z2 Bau 5'!R12C8+'" & strFileName & "Z2 Bau 5'!R24C2)*1000000"
Else
Exit Do
End If
Loop
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0
Sub pourya2()
Dim strFileName As String, strPath As String, strTemp As String
Dim i As Long
strPath = "P:\RB\RB-PM\75 Fuegetechnologie\Shopfloor Digital\Dashboard Bolzen\in Arbeit\ppm _
Stahl\2016ppm"
If Right(strPath, 1) "\" Then strPath = strPath & "\"
Do
i = i + 1
strTemp = Dir(strPath & "KW " & Format(i, "00") & " ppm Auswertung.xlsx", vbNormal)
If strTemp "" Then
strFileName = strPath & "[" & strTemp & "]"
Cells(3 + i, 3).FormulaR1C1 = _
"=('" & strFileName & "Z1 Bau 15'!R17C2+'" & strFileName & "Z2 Bau 5'!R17C5+'" & _
strFileName & "Z2 Bau 5'!R17C2+'" & strFileName & "Z2 Bau 5'!R17C5+'" & _
strFileName & "Z2 Bau 5'!R17C8+'" & strFileName & "Z2 Bau 5'!R29C2)/('" & _
strFileName & "Z1 Bau 15'!R12C2+'" & strFileName & "Z1 Bau 15'!R12C5+'" & _
strFileName & "Z2 Bau 5'!R12C2+'" & strFileName & "Z2 Bau 5'!R12C5+'" & _
strFileName & "Z2 Bau 5'!R12C8+'" & strFileName & "Z2 Bau 5'!R24C2)*1000000"
Else
Exit Do
End If
Loop
End Sub
Option Explicit
Sub pourya2()
Dim strFileName As String, strPath As String, strTemp As String
Dim i As Long
strPath = "P:\RB\RB-PM\75 Fuegetechnologie\Shopfloor Digital\Dashboard Bolzen\in Arbeit\ppm Stahl\2016ppm"
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
With Sheets("Tabelle1")
For i = 1 To 52
strTemp = Dir(strPath & "KW " & Format(i, "00") & " ppm Auswertung.xlsx", vbNormal)
If strTemp <> "" Then
strFileName = strPath & "[" & strTemp & "]"
.Cells(i + 1, 3).FormulaR1C1 = _
"=('" & strFileName & "Z1 Bau 15'!R17C2+'" & strFileName & "Z2 Bau 5'!R17C5+'" & _
strFileName & "Z2 Bau 5'!R17C2+'" & strFileName & "Z2 Bau 5'!R17C5+'" & _
strFileName & "Z2 Bau 5'!R17C8+'" & strFileName & "Z2 Bau 5'!R29C2)/('" & _
strFileName & "Z1 Bau 15'!R12C2+'" & strFileName & "Z1 Bau 15'!R12C5+'" & _
strFileName & "Z2 Bau 5'!R12C2+'" & strFileName & "Z2 Bau 5'!R12C5+'" & _
strFileName & "Z2 Bau 5'!R12C8+'" & strFileName & "Z2 Bau 5'!R24C2)*1000000"
Else
.Cells(i + 1, 3) = ""
End If
Next
End With
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0
auch mit deiner Testdatei, kein Problem.Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen