VBA - Condition - look for a certain cell value

  • Hi,


    My code looks into a folder with several xls files and opens each one of them.
    Then it copies a specific range out of a sheet and gatheres it into a new sheet.


    Unfortunately the range changes between the xls files.


    It would be necessary to look out for the common header string 'Primary Sequences',
    and then select the range (cols B to M) below this, until the next header 'Derived Sequences' occurs.


    If someone knows how to add such a condition to my code, this would be very helpful!


    I have enclosed example files.




    Cheers,
    Jurgen

  • Re: VBA - Condition - look for a certain cell value


    Jurgen,



    Ok. I'm assuming that the file "ExtractGeneSheets" should be considered as a "SOURCE" file? Also this file has macro's. If this is representative of a source ".csv" file it CAN NOT contain macros.


    In the "ExtractGeneSheets" file there is no "Primary Sequences" value! Yet in the files with "####.File.Lists" as their name it puts the values from the 2,3 file into the "Primary Sequences" section.


    Can you attach a Raw csv file ( pare it down if need be to fit size requirements ).

  • Re: VBA - Condition - look for a certain cell value


    Hi!


    Source files are the workbooks in the folder 'Gene.File.Lists'.
    The data to be extracted is under the header 'Primary Sequences'.


    'ExtractGeneSheets.xls' should contain the macro for opening and extracting the data.
    By running this macro, the workbooks in the folder 'Gene.File.Lists' should be opened, and the corressponding data (the sections under the header 'Primary Sequences', as described above, should be copied and collected into the actual worksheet of 'ExtractGeneSheets.xls'.


    The data you can see in the file is just the result of the macro code I ran, which you can see above.

  • Run-time error '1004', application-defined or object-defined error


    Hi,
    I tried to search for the two headers, using the .find method.
    With the following code, I get the error message
    "Run-time error '1004', application-defined or object-defined error" for line
    bla = ActiveWorkbook.Worksheets("Sequence Data").Range("B" & lStart & ":M" & lEnd)


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!