I have a large VBA project that I've been tasked with changing how it gathers some data.
Basically, the data will be entered in column W on the sheet and it's code in the Macro is this:
For Each rCell In Worksheets("REPORT").Range("W2:W50")
Debug.Print rCell.Value:
sJob = rCell.Value
It grabs the data I want it to grab in column W.
Shortly after that, it kicks off a function that is in this block of code:
vJobFolders = Split(FindJobDir(strpathtofile & sJob), ",")
For i = 0 To UBound(vJobFolders)
And that function, called FindJobDir, looks like this:
Function FindJobDir(ByVal strPath As String) As String
Dim sResult As String
sResult = Dir(strPath & "*", vbDirectory)
FindJobDir = UCase$(sResult)
Do While sResult <> ""
sResult = Dir
If Len(sResult) > 0 Then FindJobDir = FindJobDir & "," & UCase$(sResult)
Loop
End Function
What is happening, after it grabs all the data it can find it column W, it just continues to add everything in the job path. It doesn't stop until all "jobs" in that path are found. I need it to stop doing that when data in column W is null/empty.
Not being a pro at VBA, don't know what to say or where...any suggestions?