Posts by juergenkemeter

    Hi,
    When running the following function, there will be an error message 'subscript out of range'. I can't get to the point, why this happens.


    If anyone has a suggestion, I would appreciate that.


    I also enclosed the file where this happens.


    Cheers
    Juergen

    Re: select all rows and autofit them


    Hi,
    thanks.
    There is much text in the columns. I think with your code, the columns would get very wide.
    I recorded a macro, selecting 'Cells', and ticking off the option 'wrap text'. This works fine - the rows are more viewable now.



    Juergen

    Re: "IF the row has values, do..."


    The code shown is part of a function, which openes workbooks in a folder, processes out different data sections (as working like this code example), and then closes the workbook without saving. The filename in column N is therefore no problem.


    If interested, I can post the whole function for better understanding - perhaps you can make a comment to my code, as I consider myself not as an advanced programmer?


    Ah well - here it is (comments still have to be improved):

    columns next to M


    Generally, the filename is written into column N, when there is data in the row.
    Then a section is copied into a MasterFile for further data export.


    Re: "IF the row has values, do..."


    Thanks.
    I tried

    Code
    Dim y As Long
                    For y = lStart To lEnd
                        If WorksheetFunction.CountBlank(ActiveWorkbook.Worksheets("Sequence Data").Range("B" & y & ":M" & y)) >= 1 Then
                             ActiveWorkbook.Worksheets("Sequence Data").Range("N" & y).Value = ActiveWorkbook.Name
                    
                        Else
                        End If
                    Next y


    I think that the code counts the blanks. If there are more than one blank cells in a line, then the Name of the Workbook is added in another column.


    What I initially searched for is, "is there any cell with a VALUE in a line". If yes, add the name of the workbook.


    Perhaps something like

    Code
    If WorksheetFunction.CountA(.Rows(y)) > 0 Then


    would be good, but this Function is not supported by the method...



    Cheers
    Juergen

    Hello,


    I am fighting to implement the following Pseudocode in VBA.


    I have a certain range of an Excel Sheet, e.g. 'A4:J9'.


    "Look into each row in this range. If there is one or several values in a cell of a row, [do something]."


    Any help is appreciated.



    Cheers
    Juergen

    Re: delete rows in worksheet if columns A to J are empty


    Does the code actually look in the range columns A to J? I think it looks if the entire row has no values, then delete it.


    My aim is that if there is no data in this range -->delete entire row.
    If there is data in the range cells -- go to next row.


    It can be that e.g. in column K or L, there is actually data in the cells, but the code should just ignore them and look at A to J, if there is any data.


    Cheers
    Juergen

    Re: VBA - Macro to remove all empty rows in a worksheet


    Hi,
    I tried



    to delete all rows which have no value in range B to M. Somehow it does nothing special...
    I enclosed an example workbook.


    cheers
    Juergen

    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)


    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.

    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: extracting whole range of sheet data


    Hi,
    I have solved this problem using the following code:


    Cheers
    Juergen

    Re: extracting whole range of sheet data


    Hi!
    I have tested the code, what it does is that it opens the three xls files in the folder. In the end I can see in the current worksheet that the actual macro VBA Code is being copied three times into the worksheet...


    Cheers
    Juergen