Solved

Macro for  copying  and pasting with conditions.

Posted on 2013-01-30
4
193 Views
Last Modified: 2013-03-14
I want to build a Macro that runs to do the following:
I have two tables 10col x 365rows. Table A has random values. This values are in form of a result from a formulas that the cell has. Rest of the cells in Table A has no values but has formulas in it. I want to run a Macro that would copy and paste only numeric values  into corresponding cells in Table B (Deposit #1 to Deposit #1; Disc to Disc etc. see the attached file pl.). The condition is that: if the Cells in Table A has no value "null" then those cells are ignored and null values or the blank cells are not copied over to Table B, only cells with numeric values are copied as numbers e.g. 234.45. Table B would have randomly populated cells already. The cells with Numeric values in Table B must not be overwritten. Cells form Table A to Table B should be only copied if the corresponding cells in Table B are empty/blank.
Macro-file.xlsm
0
Comment
Question by:hpjethwa
  • 4
4 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 38840163
I see you have both tables in the same sheet.
can we have by any chance each table in a sheet ? like Table A in sheet1 and Table B in Sheet2 ?
then you say 10 col x 360 rows but here again the tables are not 10 columns but 12 for B and 8 for A.
Also the tables have not the same columns so I guess you want to match Column per column right and the rest of columns in B not to be touched if not in A right ?

Also we need to have your header row fixed so if you agree to put each table in a sheet then remove Table A and Table B and have row 1 as your field headers.

I have attached the workbook as explained above check it and tell me if it is not too much hastle and if you agree to proceed this way.

gowflow
Macro-file.xlsm
0
 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
ID: 38840735
Well in any case, here is the macro with my proposed tables like in the attached.

To run it make sure your macroes are activated and goto TableA and activate the button Transfer to Table B and check the results in TableB I created a TableB bckup to keep your original values as backup (just to check).

I added a line of code for easy checking that is coloring in Red all the values that were updated so you can easily spot them.

Let me know outcome.
gowflow
Macro-file.xlsm
0
 
LVL 29

Expert Comment

by:gowflow
ID: 38842756
Did you have a chance to try the proposed solution ?
gowflow
0
 
LVL 29

Expert Comment

by:gowflow
ID: 38901165
Any news ?
gowflow
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

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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