Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Stop display of alerts in Word via Excel 12 23
enable formatting rows through Thsworkbook VBA code 5 15
Adding Additional Criteria to a formula 17 47
Clear a Text Box 7 27
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…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

827 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