Solved

Excel 2010 - Copy data from specific cells in one worksheet to new row in another worksheet

Posted on 2012-04-10
3
1,513 Views
Last Modified: 2013-08-08
Hi Experts,

I'm looking for some Excel VBA help to accomplish the following task. I have an Excel worksheet with information in random cells. If it helps, I'll say that I have information in cells G1:G3, J2, K3, E10, E12, E14, E16, E18, J11:J16, G19, I19, and G21. As you can see, it's not a specific range of cells.

What I'm looking to do is create a macro that I can tie to a button which will take the data from the cells I specify (listed above) and copy the VALUES (some of the cells use formulas) into a row in another worksheet called "Data" when the button is clicked.

Every time I enter new data into these cells and click the button, I'd like the macro to copy the most recent data entered into a new row below the previous row that was copied to in the "Data" sheet.

Is there any way to do this? Please help! : )
0
Comment
Question by:ambientsbs
3 Comments
 
LVL 9

Accepted Solution

by:
armchair_scouse earned 500 total points
ID: 37829060
This looked like an odd request because you said the information was in random cells...  bizarrely, that appealed to my warped sensibilities!!

I've knocked up an example in Excel that is a macro-enabled workbook.  It comprises 3 worksheets:  
Data Entry (for where you are entering data)
Record (this is what would happen when you wanted to record your changes)
Change Locations (this is Excel storing what you have changed since you last recorded anything)

There is some event code (Workbook_SheetChange) which is fired whenever you make a change to a worksheet within the workbook.  I have added an IF statement to say 'do not do anything unless the change is on the Data Entry sheet'.  There is also a procedure called TransferChanges().  It needs some tidying up (I'd do it myself except I have a train to catch to take me home!!), but basically TransferChanges() is what you would run behind your button to record any changes.  Whenever you update a cell on Data Entry, the workbook event code records the address of the cell that was changed on the Change Locations sheet.  Then when you click your button to fire TransferChanges(), it loops through the list of changed cells, looks up the values in the cells and writes them to the Record sheet.

Hopefully this should give you a big head start on what you need, even if the code is not my best (tired and I want to go home!!!!)

Hope this helps
RandomDataRecord.xlsm
0
 

Author Closing Comment

by:ambientsbs
ID: 37829208
Perfect!! This should do exactly what I need. Thank you very much for your help and have a safe train ride!
0
 

Expert Comment

by:robertjread
ID: 39392808
Hi there, loving this

but really need to see if i can get the information into a defined order.

i.e. say i have created a front sheet that looks like a form i will want to take the information entered into the random cells (data will change but cells remain the same) and create a list as stated above, this list then becomes my log of the front form.

to give you back ground i am creating a Monitoring form and wish to create a log off teh back of it to track results.  

ideally there would be a button on teh front page that creates the log.  

Can you help?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Compare Excel spreadsheet - 1 3 37
Using range instead of selection (VBA) 4 39
Input box prompt with only 5 possible entries 5 40
Calculate number of months in Excel 13 25
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question