Solved

Copy certain cells from one file paste to another then print using a macro.

Posted on 2016-08-12
12
39 Views
Last Modified: 2016-08-18
I'm new to Excel Macros and VBA so thank you in advance for any help.
I have an excel report that has multiple rows and each day the number of rows changes. What I want to do is copy certain cell data from each row in this report and paste that data into certain cells of a different work book, then have that work book print.

 In hopes of simplifying it, It would go something like this: Workbook1: copy cells C9, F9, H9 Workbook2: Paste into cells C10,C11,C12 respectively then print Workbook2. This would then move to the next row in Workbook1 and continue until it finds empty rows.

Items that change daily are Workbook1 name and the number of rows in Workbook1. The cells that I'm copying from and pasting to and the name of Woorkbook2 would all be static.

I know the copy and paste function is possible but I'm not sure about the printing or making it move row by row until it finds empty rows.

Again, Thanks in advance for any help.
0
Comment
Question by:Member_2_7971385
  • 6
  • 5
12 Comments
 
LVL 18

Expert Comment

by:Roy_Cox
ID: 41754598
Why move to individual rows? It would be quicker to copy all the cells in action if they are all in the same column. Provide a dummy workbook with before and after examples.
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 41754641
also consider hiding columns of the source workbook, then printing that.

use the macro recorder to try it out and we can help improve the macro,
0
 

Author Comment

by:Member_2_7971385
ID: 41756326
I apologize. I may have over simplified my example. In the original report (workbook1) there are normally around 15 rows. Sometimes more sometimes less. Each row is a high priority item for for a specific dealer. I only need certain cells out of each row and not the whole row. What I'm trying to avoid is the end user having to hand write the data that they need (Date, Dealer,Style,Serial Number) on a "hold for special inspection" form that is placed on the item for further inspection. This is all in hopes of saving time and eliminating human error.

I have attached a sample of the report that the cells need to be copied from and a sample of the form that they need to be copied to. I've Color coded what needs to go where. Again, each row is a separate item with a separate form to be printed out.
hpreport34.xlsx
SpecialInsp.xlsm
0
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.

 

Author Comment

by:Member_2_7971385
ID: 41759669
The copy and paste isn't a problem. I just can't figure out how to go row by row and print after each.

Again, thanks for any help.
0
 
LVL 18

Expert Comment

by:Roy_Cox
ID: 41759791
What about ABC Corp which has data on two Rows?
0
 

Author Comment

by:Member_2_7971385
ID: 41759806
Each row is a different serial number / product and needs to have the form printed out to be held for special inspection.
0
 
LVL 18

Expert Comment

by:Roy_Cox
ID: 41759879
I have written some code for you. I'll post it later when I have had time to test it
0
 
LVL 18

Assisted Solution

by:Roy_Cox
Roy_Cox earned 500 total points
ID: 41759892
I think this works.

I have put the code in the data workbook and edited the form workbook by removing the mergedcells - never use them they usually create problems.

Run the code and it will prompt you to choose the form workbook and will then print preview each report.

I can move the code to the form if you want and once you are satisfied we can change print preview to print.

I'll check back later
hpreport34.xlsm
Form.xlsm
0
 

Author Comment

by:Member_2_7971385
ID: 41761274
That looks great. The only thing I see is it pulled the wrong cell over for the "Dealer" Line. Also, will it continue to the next row after the first row has printed and so on? I would rather have the code and button in the form as the report is emailed from another system and changes daily.

This probably wasn't the best first VBA project to tackle but I really appreciate the help.
0
 
LVL 18

Accepted Solution

by:
Roy_Cox earned 500 total points
ID: 41761320
I have moved and re-written the code for you. The button is now in the forms workbook and I have set it not to print.

I have made some corrections to the code so I think it will now run as you want.
Form.xlsm
hpreport34.xlsx
0
 

Author Comment

by:Member_2_7971385
ID: 41761856
That is exactly what I needed it to do. Thank you again!
0
 
LVL 18

Expert Comment

by:Roy_Cox
ID: 41761989
No problem, pleased to help
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Finding a closest match in Excel 7 36
Capture ESC press reliably without error 2 31
Excel - Data Validation 3 26
Excel Question 17 15
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…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

813 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

10 Experts available now in Live!

Get 1:1 Help Now