+ Reply to Thread
Results 1 to 5 of 5

Rewrite a function to read a list from external file

  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.

    Please Login or Register  to view this content.
    The way I am calling the function is like this:
    Please Login or Register  to view this content.
    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.

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

    Re: Rewrite a function to read a list from external file

    Please Login or Register  to view this content.
    This is what my non-functioning rewrite is looking like so far. Firstloop is a Boolean set to true at the top of the macro in my attempt to not open and reread the file for every account number it tries to compare. I have also tried the following loop without success.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    This is my revised call to the function.

    Current issues:

    Firstloop seems to empty when I call the function
    Type mismatch error on the line: Do Until i = UBound(FlaggedAccts) and/or For i = 1 To UBound(FlaggedAccts)
    I know I will need to split the FlaggedAccts array as it will contain the string "1234, Reason" when it's working but I'm still not getting the framework to behave as expected.
    I have little to no idea what I'm doing.
    Last edited by smpita; 04-25-2014 at 05:28 PM.

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

    Re: Rewrite a function to read a list from external file

    I am closing in on my own solution!

    First, to make Firstloop keep it's data, I changed it's declaration from DIM to Private. Other than that function call remains the same as above. Here is my almost working function.

    Please Login or Register  to view this content.
    Current issues:

    I suck with arrays. My array FlaggedAccts has the info, just need to figure out how to loop through it properly in this part.
    Please Login or Register  to view this content.
    I am still getting a type mismatch on the For loop.
    Last edited by smpita; 04-25-2014 at 06:32 PM.

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

    Re: Rewrite a function to read a list from external file

    My inexperience is getting the better of me. This is what it looks like now due trying to figure out the "Subscript out of range" and "Type mismatch" errors.

    Please Login or Register  to view this content.

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

    Re: Rewrite a function to read a list from external file

    This works for now. Posted for anyone going through similar coding.

    Please Login or Register  to view this content.

+ Reply to Thread

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. 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