Thursday, November 11, 2010

How do I make a cut & paste VB code from one sheet to another in Excel based on a condition?

I would like to enter data on the first sheet and depending on the value of one of the cells, have it moved to the appropriate sheet.



For example,



If the value of a cell is %26gt;= 10, then the entire row gets moved to Sheet X.

If the value of a cell is %26gt;= 9 AND %26lt; 10, then the entire row gets moved to Sheet Y.





And so on.



Thanks in advance.How do I make a cut %26amp; paste VB code from one sheet to another in Excel based on a condition?
Try this youtube channel - This guy has a lot of VBA for Excel video tutorials and some talk about copy/past values.How do I make a cut %26amp; paste VB code from one sheet to another in Excel based on a condition?
In the VBA, you test the value in the cell(s) of interest, and if the value is 9, set the RANGE to the entire row, move it to the corresponding row in sheet Y. If the value is more than 9, move it to sheet X. You will have to trigger this code to execute when an event, such as the enter key is pressed.



It isn't hard to do if you know some VBA.
The results you get will be unsatisfactory when you go that route. VBA has to test for every key stroke and act without thinking. What if you made a mistake and need to undo?



Instead why don't you go ahead and enter the data like any normal spreadsheet.



Next look up features like autofilter which you can use to copy any filtered rows to another sheets. This way you are working on one original source without having to maintain separate worksheets.

No comments:

Post a Comment