Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Loop until all files are placed


Hi Guys, 

I am unable to code my logic into the code & it is little bit complicated for me so plz help me in solving the same 

Thnx for the help

Sub create()
Dim wb3 As Workbook
Dim wsh3 As Worksheet
Dim Fso As Object
Dim PrvStock, NoTData, S1, S2, S3, S4 As String
Dim LineStr, HH As Variant
Dim P1, P2, P3, P4, P5 As Integer
Dim OoTxt, NpTxt, CoTxt, NoATxt, TxtFileInAnother As Object
Dim SqOffTxt As Object
Dim OoData, NpData, SqData As String
Dim SqData2 As Variant
Dim FoPath, MissingFile, pass1, Pass2 As String
Pass2 = "downloaded"
Set Fso = CreateObject("Scripting.FileSystemObject")
FoPath = "C:\Users\WolfieeeStyle\Desktop"
Set wb3 = Workbooks("BasketOrder.csv")
Set wsh3 = wb3.Sheets(1)

If wsh3.Range("A2") = "NSECM" Or Dir(FoPath & "\TechnicalGlitch.txt") <> "" Then

If Dir(FoPath & "\np.csv") <> "" Then
Kill FoPath & "\np.csv"
ElseIf Dir(FoPath & "\oo.csv") <> "" Then
Kill FoPath & "\oo.csv"
ElseIf Dir(FoPath & "\co.csv") <> "" Then
Kill FoPath & "\co.csv"
End If

After this I need below logic into the code

Loop until np.csv & oo.csv & co.csv is placed in the fopath & If Any file is missing Then Create a InputBox Stating Missing File(File name ) & That inputBox will only be closed by putting paasword




Don't think I'll have time to look at this today but please attach a representative Excel file (to save respondents time).

Also, did my answer to you recent question "Block If without End If" help? (You didn't select it or comment) 
John_Ru (rep: 4282) Sep 27, '22 at 8:02 am
Please note your question only just appeared online for me (I think Don is travelling so has little time to moderate new questions to avoid spam attacks)
John_Ru (rep: 4282) Sep 27, '22 at 8:04 am
No answer from you so I assune you've solved your problem, right? 
John_Ru (rep: 4282) Sep 28, '22 at 6:40 pm
Add to Discussion

Answer the Question

You must create an account to use the forum. Create an Account or Login