VBA macro for copying conditional data to specific cells

前端 未结 5 2025
太阳男子
太阳男子 2021-01-26 11:57

I\'m new to programming in VBA and I\'m looking To take data from different worksheets that matches a condition. Then copy and paste from one specific cell to another specific

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-26 12:52

    The If should be like this:

    If Sourcews.Range("AA"&i).Value = "Needed Value" Then

    Then in the Pastews.Cells, it should be refered to the Worksheet like this:

    pastews.Range("A18").Copy Destination:=pastews.Range("H18")
    

    or

    pastews.Cells(18,1).Copy Destination:=pastews.Cells(18,8)
    

    Here is the MSDN article about ranges in VBA - it's worth reading - https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-object-excel

提交回复
热议问题