Excel/moving data - Excel 2010
QUESTION: Running Excel 2010.
I have a spreadsheet (Sheet 1) which has multiple sections. In each section, the rows have drop down lists to select materials, and when selected, the adjacent columns automatically fill in the cost when a quantity is entered.
Each section has between 4-10 rows with 5 columns in each row. Sometimes all rows will be selected and other times perhaps only one. This will leave empty rows and columns.
I need to gather all the materials that have been selected from the various sections and place them in Sheet 2. Starting with the first section, all the data (material, quantity, price) needs to be moved to the Sheet 2. Then, the data selected in the second section needs to be moved and place in the row immediately after the end of the first data moved. No empty rows.
I need this to automatically update/change if the information on Sheet 1 is modified.
This is needed to create a single “pick list” of materials and costs, consolidated onto a single Sheet.
Hope you can help me.
ANSWER: Right-click the sheet tab, paste in this code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Set curr = Selection
Application.ScreenUpdating = False
Application.CutCopyMode = xlCopy
Application.ScreenUpdating = True
---------- FOLLOW-UP ----------
QUESTION: Thanks for reply. It appears simple but I don't speak Greek. :) Is it possible to have an explanation of how I apply this. Where would I enter the ranges of cells that would be copied? I guess I'm not sure where the variables are in this code or how it would be executed. Thanks again.
It runs automatically whenever anything on the sheet changes. There's nothing else to do aside from Right-click the sheet tab, select View Code, paste in the code.
It automatically copies every set of contiguous ranges. For example, if you have data in A1:E5 and A12:E19, when you make ANY change, both those ranges will be copied and pasted as one block onto sheet2, taking up A1:E13.
Try it; you'll like it.