Hello Excel Forum!
I have a macro that uses the following function.
Function FlagDep(AcctNo As String)
' Check if an account number is flagged for
' special handling
If AcctNo = "" Then GoTo FlagDep_Err
Select Case AcctNo
Case "1234", "12345", "123456"
MsgBox "Account number " & AcctNo & " needs special handling. Check account notes."
Case Else
End Select
Exit Function
FlagDep_Err:
MsgBox "No account number specified."
End Function
The way I am calling the function is like this:
For Each cell In Range("A1:A" & Range("B1").CurrentRegion.Rows.Count)
If Not cell.Value > "0" Then
MsgBox "You're not done entering account numbers"
GoTo VeryEnd
Else
If DepReady = True Then FlagDep (cell.Value)
End If
Next cell
I need to rewrite this function to make it more portable with other people.
Instead of getting the list of flagged account numbers from Select Case, I need it to pull the list from an external file. Let's call the file Z:\Flagged.csv for the sake of convenience. The file will be in .CSV format. Account numbers that need to trigger the MsgBox will be in the A column, one account number per row like in my example: Flagged.csv. There will be data in the B column that needs to be ignored.
Is there a simple way to do this? I suspect there is but I've never worked with making a macro read data from another file and my search results are proving confusing.
Thank you in advance for any help that you can offer!
Bookmarks