[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2012-04-10
3
Medium Priority
?
1,541 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 2000 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

Industry Leaders: 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

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!
This article describes a serious pitfall that can happen when deleting shapes using VBA.
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 two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

873 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