0

The user select a path for a file and click yes, each path file are inserted in a worksheet(Column1).

I try to make a loop to read this path file in the worksheet(Column1) until the end of records

This is the code I try but do not work well because when the path is ="" I get an error. So I want to quit the when the file path is =""(cell = "")

    Do Until Workbooks(1).Worksheets(3).Cells(cnt, 1).Value = Null

    fileName = Workbooks(1).Worksheets(3).Cells(cnt, 1).Value


    Set oFS = oFSO.OpenTextFile(fileName) //If fileName="" I get error

    Do Until oFS.AtEndOfStream
        sText = sText & oFS.ReadLine
    Loop
    Debug.Print sText
    cnt = cnt + 1

RE6 sText, fileName

Loop

Thanks Frank

1 Answer 1

1

Why not just check for Trim$(Cell.Value) = "", rather than Null, on the first line?

Sign up to request clarification or add additional context in comments.

2 Comments

Do Until Trim$(Workbooks(1).Worksheets(3).Cells(cnt, 1).Value) = ""
Do Until Workbooks(1).Worksheets(3).Cells(cnt, 1).Value = EmptySting Is the cleanest way thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.