Solved

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

Posted on 2012-04-10
3
1,504 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now