Macro for  copying  and pasting with conditions.

Posted on 2013-01-30
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.
Question by:hpjethwa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
LVL 30

Expert Comment

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.

LVL 30

Accepted Solution

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.
LVL 30

Expert Comment

ID: 38842756
Did you have a chance to try the proposed solution ?
LVL 30

Expert Comment

ID: 38901165
Any news ?

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
Excel Match and move 7 18
Permutacion of 2 numbers COUNT 8 21
Excel userform issue. 15 18
Entering Time without using ":" (full colon) 2 14
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.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

710 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