Home

Printing based on Cell value - VBA???

%3CLINGO-SUB%20id%3D%22lingo-sub-377767%22%20slang%3D%22en-US%22%3EPrinting%20based%20on%20Cell%20value%20-%20VBA%3F%3F%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-377767%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20All%20-%20first%20time%20post.%26nbsp%3B%20Not%20a%20rookie%20to%20Excel%2C%20but%20no%20expert%20either.%26nbsp%3B%20I%20am%20stuck%20trying%20to%20automate%20a%20print%20function.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20table%20which%20is%204%20columns%20as%20follows%3A%3CBR%20%2F%3E%3CBR%20%2F%3EFull%20Name%20%7C%20Rating%20%7C%20Comments%20%7C%20Performed%20By%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20%22Preformed%20by%22%20field%2C%20i%20have%20my%20staff%2C%20and%20there%20are%20repeats%20of%20staff.%26nbsp%3B%20So%20this%20column%20(column%20D)%20has%20repeats%20of%20%22John%20Smith%22%20(3x)%2C%20Sam%20Jones%20(4x)%2C%20Mike%20Adams%20(1x).%26nbsp%3B%20Each%20of%20the%20other%20columns%2C%20while%20there%20may%20be%20repeating%20information%2C%20should%20be%20treated%20as%20independent%20data%20(so%20a%20name%20of%20Sue%20Smith%2C%20which%20may%20repeat%20once%20or%20twice%20is%20not%20related%20to%20the%20important%20column%20of%20%22Performed%20By%22).%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20print%20each%20range%20of%20values%20for%20a%20particular%20staff%20person%20on%20an%20individual%20page%20(or%20pages%20if%20necessary)%20to%20hand%20out%20to%20that%20person%20individually.%20So%20is%20staff%20person%20John%20Smith%20has%205%20reviews%2C%20that%20the%20customer%20name%2C%20the%20rating%20and%20comments%20all%20print%20on%20a%20single%20page%2C%20in%20a%20table%20format%20in%20the%20same%20manner%20as%20though%20I%20manually%20selected%20that%20range%20of%20values%20and%20printed%20using%20the%20%22Print%20Selected%22%20function.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20attached%20a%20sample%20spreadsheet%20to%20demonstrate.%26nbsp%3B%20I%20need%20each%20staff%20person's%20reviews%2C%20customer%20name%20and%20rating%20to%20print%20on%20a%20single%20page%20based%20on%20the%20staff%20persons%20name.%26nbsp%3B%20ONE%20CLICK%20or%20FUNCTION%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%2030%20staff%2C%20each%20with%20more%20than%20a%20few%20ratings%20to%20print%20for%20them%2C%20so%20I%20am%20looking%20for%20a%20way%20to%20automate%20this%20in%20some%20way%2C%20and%20I%20figure%20VBA%20is%20probably%20the%20best%20option..%3F%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20am%20open%20to%20providing%20more%20input%20as%20needed.%26nbsp%3B%20Feel%20free%20to%20ask.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20so%20Much%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EJustin%26nbsp%3B%3CBR%20%2F%3EMichigan%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-377767%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eprint%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EVba%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-386240%22%20slang%3D%22en-US%22%3ERe%3A%20Printing%20based%20on%20Cell%20value%20-%20VBA%3F%3F%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-386240%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F304603%22%20target%3D%22_blank%22%3E%40Justin_L%3C%2FA%3E.%26nbsp%3B%20Sorry%20for%20the%26nbsp%3Blate%20replay.%20I%20am%20not%20sure%20if%20I%20understand%20your%20question.%20Can%20you%20provide%20more%20details%20about%20the%20situation%20and%20the%20problems%20you%20are%20running%20into%3F%3C%2FP%3E%3CP%3EWhere%20is%20the%20data%20coming%20from%3F%20Which%20details%20on%20the%20sample%26nbsp%3Bsituation%20are%26nbsp%3Bdifferent%20from%20the%20real%20situation%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-382746%22%20slang%3D%22en-US%22%3ERe%3A%20Printing%20based%20on%20Cell%20value%20-%20VBA%3F%3F%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-382746%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAgain%2C%20thank%20you.%26nbsp%3B%20I%20am%20stuck%20on%20getting%20the%20table%20labeled%20correctly%20to%20where%20the%20macro%20will%20run.%26nbsp%3B%20Can%20you%20provide%20some%20insight%3F%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-379750%22%20slang%3D%22en-US%22%3ERe%3A%20Printing%20based%20on%20Cell%20value%20-%20VBA%3F%3F%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-379750%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20worked%20just%20perfectly%20for%20what%20I%20need....%26nbsp%3B%20the%20next%20question%20is%20HOW%20you%20got%20there%20so%20I%20can%20import%20it%20into%20the%20ACTUAL%20report!%26nbsp%3B%20I%20run%20this%20report%20anywhere%20from%20once%20a%20quarter%20to%20once%20a%20month%2C%20and%20so%20I%20will%20need%20to%20repeat%20this%20with%20some%20regularity!%20And%20I%20will%20want%20to%20make%20sure%20it%20will%20translate%20to%20a%20new%20report%20each%20time.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20appreciate%20it%20though!%26nbsp%3B%20It%20works%20great!%20Thank%20you%20so%20much!%26nbsp%3B%20You%20just%20saved%20me%20HOURS%2C%20literally!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-378042%22%20slang%3D%22en-US%22%3ERe%3A%20Printing%20based%20on%20Cell%20value%20-%20VBA%3F%3F%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-378042%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F304603%22%20target%3D%22_blank%22%3E%40Justin_L%3C%2FA%3E%26nbsp%3B.%3C%2FP%3E%3CP%3EHere's%20a%20quick%20solution%20for%20you.%20It%20could%20still%20use%20a%20few%20tweaks%20to%20the%20design%20and%20practical%20aspects%2C%20but%20it%20is%20doing%20what%20you%20need.%20Just%20hit%20the%20%22staff%20sheets%22%20button.%3C%2FP%3E%3CP%3EBelow%20you%20can%20read%20a%20summary%20of%20the%20steps%20that%20I%20took%3A%3C%2FP%3E%3CP%3E-%20Transformed%20data%20into%20an%20Excel%20table.%3CBR%20%2F%3E-%20created%20a%20list%20of%20unique%20staff%20names%20and%20put%20it%20into%20a%20table.%3CBR%20%2F%3E-%20Tables%20allow%20you%20to%20add%20more%20data%20to%20it%20without%20the%20need%20to%20update%20formulas%20or%20VBA%20code%20to%20account%20for%20the%20new%20data%20range%20(if%20they%20were%20properly%20set%20up).%3C%2FP%3E%3CP%3E-%20To%20obtain%20the%20desired%20results%2C%20make%20sure%20that%20the%20same%20staff%20member%20is%20always%20spelled%20the%20same%20way.%20(Data%20validation%20with%20a%20dropdown%20menu%20is%20in%20place%20in%20the%20last%20column%20of%20the%20data%20table.)%3CBR%20%2F%3E-%20set%20columns%20A%20to%20D%20as%20Print%20Area%3CBR%20%2F%3E-%20Set%20printing%20scale%20as%20fit%20all%20columns%20into%20one%20page%3CBR%20%2F%3E-%20created%20a%20macro%20that%20goes%20through%20the%20staff%20list%20and%2C%20for%20each%20name%20filters%20the%20data%20table%20by%20that%20name%20and%20then%20creates%20a%20PDF%20printing%20of%20the%20visible%20rows.%20PDF%20files%20are%20saved%20in%20the%20same%20folder%20as%20the%20Excel%20file.%20At%20the%20end%20of%20the%20process%2C%20the%20table%20filters%20are%20cleared.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20this%20helps%20and%20I%20wish%20you%20and%20your%20team%20lots%20of%20fantastic%20reviews.%3C%2FP%3E%3CP%3ECheers!%3C%2FP%3E%3CP%3ECelia%20Alves%3C%2FP%3E%3C%2FLINGO-BODY%3E
Justin_L
New Contributor

Hello All - first time post.  Not a rookie to Excel, but no expert either.  I am stuck trying to automate a print function. 

 

I have a table which is 4 columns as follows:

Full Name | Rating | Comments | Performed By

 

In the "Preformed by" field, i have my staff, and there are repeats of staff.  So this column (column D) has repeats of "John Smith" (3x), Sam Jones (4x), Mike Adams (1x).  Each of the other columns, while there may be repeating information, should be treated as independent data (so a name of Sue Smith, which may repeat once or twice is not related to the important column of "Performed By"). 

 

I want to print each range of values for a particular staff person on an individual page (or pages if necessary) to hand out to that person individually. So is staff person John Smith has 5 reviews, that the customer name, the rating and comments all print on a single page, in a table format in the same manner as though I manually selected that range of values and printed using the "Print Selected" function.  

 

I have attached a sample spreadsheet to demonstrate.  I need each staff person's reviews, customer name and rating to print on a single page based on the staff persons name.  ONE CLICK or FUNCTION

I have 30 staff, each with more than a few ratings to print for them, so I am looking for a way to automate this in some way, and I figure VBA is probably the best option..? 

I am open to providing more input as needed.  Feel free to ask. 

 

Thanks so Much 

Justin 
Michigan

 

 

 

4 Replies

Hi, @Justin_L .

Here's a quick solution for you. It could still use a few tweaks to the design and practical aspects, but it is doing what you need. Just hit the "staff sheets" button.

Below you can read a summary of the steps that I took:

- Transformed data into an Excel table.
- created a list of unique staff names and put it into a table.
- Tables allow you to add more data to it without the need to update formulas or VBA code to account for the new data range (if they were properly set up).

- To obtain the desired results, make sure that the same staff member is always spelled the same way. (Data validation with a dropdown menu is in place in the last column of the data table.)
- set columns A to D as Print Area
- Set printing scale as fit all columns into one page
- created a macro that goes through the staff list and, for each name filters the data table by that name and then creates a PDF printing of the visible rows. PDF files are saved in the same folder as the Excel file. At the end of the process, the table filters are cleared.

 

I hope this helps and I wish you and your team lots of fantastic reviews.

Cheers!

Celia Alves

@Celia_Alves 

 

That worked just perfectly for what I need....  the next question is HOW you got there so I can import it into the ACTUAL report!  I run this report anywhere from once a quarter to once a month, and so I will need to repeat this with some regularity! And I will want to make sure it will translate to a new report each time.  

 

I appreciate it though!  It works great! Thank you so much!  You just saved me HOURS, literally! 

@Celia_Alves 

 

Again, thank you.  I am stuck on getting the table labeled correctly to where the macro will run.  Can you provide some insight?  

Hi, @Justin_L.  Sorry for the late replay. I am not sure if I understand your question. Can you provide more details about the situation and the problems you are running into?

Where is the data coming from? Which details on the sample situation are different from the real situation?

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies