Results 1 to 5 of 5

Rewrite a function to read a list from external file

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-26-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    173

    Talking Rewrite a function to read a list from external file

    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!
    Last edited by smpita; 04-25-2014 at 05:07 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Big conditional formatting formula slowing down file, need help to rewrite
    By henkisdabro in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-21-2014, 01:27 AM
  2. Dropdown list // VLOOKUP using an external file as reference question
    By jlg_silva in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-18-2014, 11:44 PM
  3. [SOLVED] Function Ifcolorandtextthen or rewrite SUMifs with color as a criteria
    By Slowfish in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-18-2012, 11:36 AM
  4. Canceling a read file function
    By mwc0914 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2006, 02:04 PM
  5. [SOLVED] Load List from External Excel file
    By Enrique Becerra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-17-2005, 10:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1