VBA Code Modification, Command button to copy data based on row number.

  • Hi, I am using the below code which needs some modification.


    When I click on the command button, it copies the data to another sheet paste it to the defined row.


    But If there is old data that exists already it does nothing.

    I want it to clear the previous data and paste the current data.


    Here is the code:

    Hope someone helps me.


    Thanks in advance.

  • Try changing

    Code
    wsDest.Range("A1").Value = ""

    to

    Code
    wsDest.UsedRange.Clear

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • When Row changed

    It cleared the previously used range.

    I want the previous row unchanged if the row changes.

    If the row is unchanged but data changed then clear the data and impose the current data

    and If nothing changes then Nothing.


    Hope you understand.


    Suggestion Please?


    Thanks Again

  • Hi, I am trying to update the code but faild in one place that is,


    If the cell is blank data copy & paste but if data exist then it is note overwrite the existing data or do not update.


    Check this & the recommended.


  • Try

    If that does not produce the required result then you will need to attach your workbook and show expected result.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Hi, Kj box,


    It Workes perfectly. Thanks.


    If there is a possible response option that could be much better for me.


    Response = MsgBox("Are you sure you want to update?", vbYesNo, "Update?")


    If Yes then update, otherwise nothing happens.


    If it's possible in your code will be much better.


    Thanks for the work you have done for me.:thumbup:

  • I have done the above requirements, Thanks for the support.


    Thanks and keep supporting us.

  • When I want to change something in your code then this message showing.


    Can you tell me what is the problem?


    Then code is not working correctly.


  • Hi, There may some problem with your code.


    It copies only the 3rd cell and paste 3rd cell data to 23 to 25.


    Sorry to say,


    What happened. It becomes simple to complex.

  • Try

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You're welcome

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

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