+ Reply to Thread
Results 1 to 2 of 2

Find variable range of cells,then loop through verification check on separate wk book

  1. #1
    Registered User
    Join Date
    06-21-2011
    Location
    Houston
    MS-Off Ver
    Excel 2007
    Posts
    2

    Find variable range of cells,then loop through verification check on separate wk book

    I've tried to reasearch this on here and many other places (including reading some of John Walkenbach's Excel 2007: Power Programming with VBA). I guess there is somehing that is still not clicking yet, and so I am turning to the the wonderful people of this forum for some assistance. This is a little more complex than the title suggests but I did not know how to condense it any more while remaining coherent.

    I have attached a small sample worksheet as well as a verification worksheet that I will explain below:

    First, a few things when looking at the sample file:
    In column A, a value of "8" signifies the beginning of a data type. In Column E on that same row is a 2-digit number defining the data type. Then, every row following a row w/ an "8" in Column A will have a "4" in Column A, signifying that the cells in that row are the data. The end of the data for that data type is signified by a "9" in Column A. Then, the next row will start a new data type that has completely different data/ different # of columns, etc.

    It's similar to html code, in that you have the wrappers at the beginning and end of what you're appling it to (ex: [ QUOTE] quoted text goes here [ /QUOTE]). The row starting with an "8" in C1 being the "[ QUOTE]", the rows starting with a "4" in C1 being the quoted text, and the row with a "9" in C1 being the "[ /QUOTE]" (Or you can think of the 8 and 9 as the header/footer of each data type within the worksheet)

    In short, you would read the attached sample worksheet as the "8" in R3C1 indicates the beginning of type "11" data(R3C5). The "9" in R6C1 indicates the end of type 11 data. The "8" in R7C1 signifies the beginning of type "05" data (R7C5). This is the data type I am interested in.

    However, the beginning of type 05 data might start on row 82, or it might start on row 257. It will change every month (The sample file represents data from one month.) Additionally, the desired range will vary from month to month as well.

    I am trying to create a macro that will essentially do this:
    If a cell in Column A has valueof "8" AND Column E in the same row has a value of "05", then copy the cells in Column B starting on the next row and continue until there is a value of "9" in Column A (or, alternatively, until it reaches a row where Column A does not have a value of "4").

    I would then like to take the copied cells, loop each of them through the Luhn (MOD-10) checksum on the another workbook(attached), and then copy the values which pass the validation onto a new worksheet.

    Additionally, I need to use RTRIM on the cells taken from Column B to remove the 3 spaces, and also filter out duplicate values before running them through the validation. I dont know if this can all be done in one swoop or if I need to break this into two parts ( 1: finding and selecting the variable range in Column B and pasting to a new worksheet or workbook. Then, RTRIM and filter them, (manually if needed for simplicity). 2: Loop trimmed/filtered cells through verification check and copy all the values that pass to a new worksheet).

    Where I am getting caught up is in the fact that I dont know in which row the column will start, nor how many rows will be in the range. The files are monthly credit card transactions, so as employees are hired or leave from month to month, the number of unique values will change, in addition to the number of transactions from month to month. Also, I'm getting thrown off by the fact that everything is formatted as text (the files come to me originally as tab delimited TXT files).

    Any assistance would be much appreciated.
    Attached Files Attached Files
    Last edited by m4570d0n; 06-26-2011 at 11:36 PM. Reason: typo

  2. #2
    Registered User
    Join Date
    06-21-2011
    Location
    Houston
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Find variable range of cells,then loop through verification check on separate wk

    Okay, so I had not had time to work on this much since I made this post. I have started to write the procedures, but I'm stuck at the moment with what to do now:

    First, to find and select the cells, I have this so far:

    Please Login or Register  to view this content.
    This Sub doesn't seem to work, and I'm pretty sure there's too many "End If" statements, but this was the only way I could get it to compile without error. What do I need to do here?

    For the Luhn verification I found a function in another thread:

    Please Login or Register  to view this content.
    What I would like to do is take the trimmed values of the array from the first Sub above, filter out duplicates, then loop the array through the Luhn function above and then paste just the values that generate a result of TRUE for the Luhn function.

    Any suggestions?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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