Solved

Macro for  copying  and pasting with conditions.

Posted on 2013-01-30
4
197 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
[X]
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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 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 will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
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…

756 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