• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Macro for copying and pasting with conditions.

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
hpjethwa
Asked:
hpjethwa
  • 4
1 Solution
 
gowflowCommented:
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
 
gowflowCommented:
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
 
gowflowCommented:
Did you have a chance to try the proposed solution ?
gowflow
0
 
gowflowCommented:
Any news ?
gowflow
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now