Sheldon wrote:
I have the following VBA code -
Dim InputFile As String
Dim InputFile1 As String
Dim InputFile2 As String
FileExists As String
...
InputFile1 = "I:\TestFolder\TestFile.txt"
I would like to be able to create a For/Next loop such as:
For i = 1 to 2
InputFile = "InputFile" & i 'The value of InputFile is now equal to
InputFile1
FileExists = Dir(InputFile)
I would like for the Dir statement in the line above to go against the
TestFile.txt file (above), not the string InputFile1. How can I do
this?
What does this mean? What are you adding the "i" to? Do you want to
check for TestFile1 or TestFile2? I'm pretty sure I don't understand
your question but maybe something in the code below may point you in a
direction of a solution.
Dim InputFile As String
Dim InputFile1 As String
Dim InputFile2 As String
Dim strFileWOExt As String
Dim strExt As String
Dim intFor As Integer
Dim strFullPath As String
FileExists As String
' ...
InputFile = "I:\TestFolder\"
strFileWOExt = "TestFile"
strExt = ".Txt"
For intFor = 1 to 2
If dir(InputFile1 & strFileWOExt & inFor & strExt) "" Then
msgbox InputFile1 & strFileWOExt & inFor & strExt & "Found"
Endif
Next intFor
>
Thanks, Sheldon Potolsky
>