Solved

Macro for  copying  and pasting with conditions.

Posted on 2013-01-30
4
164 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now