Copying rows conditional RRS feed

  • Question

  • Hi!!
    I want to ask for help to do the following:

    I must join excel 4-5 books that have the same structure and once united, read row by row an ID field in that row, and then look for that row on a second book and check for that row the value of the X cell . If this value is other than "NO PLAY" then I hit the row of the book home and keep.

    A slight idea that occurs to me, a little gross is trying to do something like this:
    For each row in Origin
    valorIDFilaSrc = fila1.celdaID
    For each row Destination
    if valorIdFilaDst = valorIdFilaSrc
    if valorCeldaP! = "NO UPDATE"
    FilaEntera paste (valorIdFilaO)
    end To
    origin next row.
    end To

    In which way could do this in VBA? or rather so I can do what I need more efficient and in a macro?

    Regards and Thanks
    Friday, April 3, 2015 3:51 PM


  • Hi Dani5,

    Accoding to the description, you want to copy the rows based on the value on the sepcific cell. For achieve the goal, we can use Excel object model to atutomate this process.

    For example, we can use Worksheet.UsedRange to get the used range on the specified worksheet and than we can loop the rows via Range.Rows and get the value from range via Range.Value. At last we can use Range.Copy to copy the range to the specific postion we want.

    And here are some helpful links for starting developing Excel using VBA:
    Welcome to the Visual Basic for Applications language reference for Office 2013

    Welcome to the Excel 2013 developer reference

    In addition, a good way to learn how to navigate the object models of Word, Excel, and Powerpoint, based on what you want to do as a user, is to use the Macro Recorder.

    Hope it is helpful.

    Regards & Fei

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 6, 2015 5:40 AM