Macro To Print Document Based On Cell Data
Dec 15, 2008got a great bit of code the other day from this forum to automatically print 'x' amount of copies based on the value in cell (see below)
View 2 Repliesgot a great bit of code the other day from this forum to automatically print 'x' amount of copies based on the value in cell (see below)
View 2 RepliesI am trying to write/print a cell value in a text document but am having problems (I know what the problem IS, just can't find a solution).
Right, so my code is as follows
I'm looking for a way to set the print area based on the value of a cell. I have a worksheet that prints a 12-page document, with data pulled from separate sheets. At the bottom of these twelve pages is an additional 2-page section that I only need in certain instances.
For example, if a cell (let's call it A1) on Sheet1 says "brown," I need the print area set to include these additional pages. If that same cell ('Sheet1'!A1) reads "yellow," however, I don't need to include the 2 pages in the print area.
I have data (part numbers) in column B. They are alphanumeric, eg 29 EE.
When I receive parts I enter the quantity of pallets received in column C next to the part number in column B.
Sometimes certain parts are not received therefore the relevant cell in column C would be left blank. There are a total of 30 part numbers in column B.
I also have an A4 landscape sheet (when printed) which is formatted into two rectangular blocks (merged cells) with fonts sized 200. The lower section contains the NOW() function and the upper section contains a part number which is entered manually. If I receive 10 pallets of 29 EE I will then print out 10 copies of the sheet with the part number and current date.
The same applies with the next part number 29 HE, if I receive 3 pallets of this part I then edit the part number for the A4 sheet and then print 3 copies.
I would like to be able to just enter the quantities received into column C and then select a macro button to print out all the sheets automatically for each part.
The reason for this is to enable older stock to be used first which can be easily identified with an A4 sheet attached when it is put away in the warehouse racking.
I have a worksheet that is pretty handy right now. I have a print button that automatically sends the doc to print with the specs I want, etc, etc. It has drop down lists, data validations, etc. What I want, and this may be impossible, is when the print button is clicked excel looks at a certain cell and based on the data in that cell, it pulls over a word document and prints that along with it.
In short, the items in the drop down list in the cell I have chosen have a different disclosure that goes with each, and I would like if possbile those to be printed from word...based on which item is picked....along with the spreadsheet when the print button is clicked.
I've found some code which works to print certain pages with value in cell A1 but I need to print dynamic ranges on some of the sheets as they will have filters on so the rows ranges will be different each time.
So far this is what I have but the dynamic range part is not working:
VB:
Sub Print_All_Worksheets_With_Value_In_A1()
Dim Sh As Worksheet
Dim Arr() As String
Dim N As Integer
[Code] ....
how to print an embedded Word document using VBA? I have tried using the macro recorder but only the cryptic code below is returned:
Sub Macro2()
ActiveSheet.Shapes("Object 3").Select
Selection.Verb Verb:=xlOpen
End Sub
I have a userform from which I need to be able to print a PDF document when the command button is pressed.
User enters the document number in docnum textbox (eg. 123)
On pressing the commandbutton printdoc, I need to be able to print document 123.PDF to default printer
All PDF Documents reside in a network folder mapped to the S:PDFdrive.
If the document is not found I need to display an error message stating this and return focus back to the textbox.
If the document is found I need to display a message stating document sent to printer.
I have a list of regions in coloumn a) i need a macro that will create a new sheet within the excel document , and copy the entire row of data to the new sheet.
but it only creates a new sheet (named incidently the same as the region name) for different region names ?
ie.
australia data data data data data data data data
australia data data data data data data data data
USA data data data data data data data data
USA data data data data data data data data
USA data data data data data data data data
USA data data data data data data data data
France data data data data data data data data
for the above info there would only be 3 new sheets created within document .
I currently have this code that allows me to print a word document on one of my drives with the click of a button in excel. I need to modify it because one of the files I want to print as well is a pdf file. how to modify it so I can do that?
Set appWrd = CreateObject("Word.Application")
Set docOpen = appWrd.Documents.Open("F:groupsdeptservCDTISA.doc")
docOpen.PrintOut
docOpen.Close
appWrd.Quit
Currently I am going back and forth between an excel document and a word document cutting and pasting values from the excel spreadsheet into tables in word. The task is a regular occurance therefore I wish to create a Macro that can automate this procedure. Both the excel and word documents are fixed templates therefore once a Macro is created it can be applied to all future work of similar nature.
Each table in the word document contains 6 rows of values in a single column. The excel data is arranged in a table that is 6 rows by x number of columns (how ever many sets of values there are for the particular job) therefore x determines how many tables must exist in the word document. I move between the excel and word document cutting and pasting each column into each table. This is not so time consuming if x=10 however on occasion x=100+ and it does take time.
Anyway to use VBA to print an Excel sheet with the Microsoft Document Image Writer to a specified folder automatically? I understand and use automatic printing all the time, but I don't know how to use VBA to specify the filename and folder once it prints with the Document Image Writer.
Is it possible to do?
I want to create a macro that creates a new .xlsx document based on cell values. And input 4 tabs into each document with specified tab names. I have a document that pulls from external sources and fluctuates with amount of data per day. I envision something that will make a new document named for the contents in cell A1, then function as a control+down to create a new document for A2, then A3 until there is no content left (should mention these are lookup formulas, and if there is no data it pulls a value of "0")
Is there a way to put in the code, the tab names it would create in each new document, or would that have to look to a cell value for the naming? The tab names would be "GS", "MYSS", "COLL SHEET", and "WIRE".
I have a macro set up in Excel that formats and deletes rows matching a citeria. Once the macro runs I then manually copy the data across into Word. I would like to automate this.
I would like the macro to copy over any cells containing data iinto a new word document. I also have standard text that I would like to include at the beginning and end of the word document. With the excel data being placed in the centre.
I have searched the web and tried a couple of macros with no luck. All the macros state "' requires a reference to the Word Object library: ' in the VBE select Tools, References and check the Microsoft Word X.X object library"
I am unsure how to reference this - but I have checked and found that the object library ticked is Microsoft Word 11.0 Object Library.
Using Excel 2003 I am trying to write a macro to set the print area according to the amount of data in a particular range of cells. I find I can include this instruction
View 2 Replies View RelatedI have a sales workbook, with three sheets. Ongoing, Won, Lost, all potential sales are entered onto the Ongoing sheet and Ongoing is chosen in a column that has 3 options - Won, Lost, Ongoing, until brought to closure by winning the sale or losing it at which point Ongoing is changed to Won or Lost.
The products for sale are Audio, Video and System and at the top of the Ongoing sheet it totals those three categories as Won, Lost or Ongoing.
What I want the workbook to do is when the status of the sale is changed from Ongoing to either Won or Lost, the entire row is moved off the Ongoing sheet and placed on the appropriate Won or Lost sheet, and the totals at the top of the Ongoing sheet calculated accordingly.
One of the columns on the Ongoing sheet is 'Progress' in which a short abbreviated explanation is input of next steps of the sale. When the sale is closed, and hopefully automaticall moved to it's appropriate sheet, I'd like this text to be changed to either Won or Lost.
In Column C (C11:C28) I have Sheet Names - Descriptors and then in Column D (D11:D28) I have the "YES" or "NO" for whether the sheet should print There could be blanks rows or rows with just heading text on them.
This project uses Table of Contents and what is on the specific sheet I use a Formula [=CONCATENATE("Agenda1 - ",Agenda1!H1)] on some of the Rows. These all then Hyperlink to the appropriate worksheet. Not all Rows will have the Formula if it is easily identifiable.
The name of the sheet is Either the Name As Is Unless there is a hyphen and if there is a hyphen then the sheet name is the first word up to the space.
I'm sure this is doable with VBA I just don't know how to manipulate the - out of the names and do the appropriate sheet selections so that I can print all of the selected sheets.
My current data looks something like this:
Info Pages Print (Merged Cell Header Row)
Title YES
Implementation NO
<blank row>
Agendas Print (Another Merged Cell Header Row)
Agenda1 - FORMULA NAME1 YES
Agenda2 - FORMULA NAME2 NO
Agenda3 - FORMULA NAME3 NO
... thru Agenda7
Other Print (Merged Cell Header Row)
Other1 - Formula Name NO
Other2 - NO
Other3 - NO
My workbook has worksheets with names: Title, Implementation, Agenda1, Agenda2, Agenda3,...Other1, Other2, Other3
I want to select all of them that have the YES to Print and then send them to my printer.
I'm looking for the same thing, this great macro by Leith Ross looks for the word "buy" in kolom A starting at A2. Now this all works fine until i change the value of the colum into a if statement : =IF(C2>0;"buy";"NR"). See the attachment on what i mean. If i run the macro now i get error 91 : objectvariable or blockvariable With is not set.
I can work around it, if i hardcode the A2 with "buy" and then A3 etc with the if statement i works for some strange reason. But there must be a smarter way of doing it, that's why i came here .
I have put together a spreadsheet to help with the creation of work orders. I have a summary page that the user can define which category the work order falls under along with this I have a couple of macros set up that will print a specific work order pertaining to the category they selected. I have run in to a few problems (mostly training users) that I would like to eliminate up front.
I am looking for a macro that I can use to look at the contents of a cell (contains a word that corresponds directly to the name of one of the sheets in the work book) and print the worksheet that has the same name as the contents in the referenced cell.
I have a code Ive been trying to get to work. It works fine with selecting the print area based off a cell value, it just wont update when ever the value changes.
This is on the Sheet's code
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target Range("A1") Then Exit Sub
Call PrintbyName
End Sub
And this is in a module
Sub PrintbyName()
Dim rng1 As Range, rng2 As Range, rng3 As Range, rngPrint As Range
'Refer to the named ranges
With Worksheets("Permit Page")
Set rng1 = Range("$A$1:$bx$603")
Set rng2 = Range("$A$1:$bx$493")
Set rng3 = Range("$A$1:$bx$493,$a$549:$bx$603")
[code]......
I wasnt sure if I was suppose to fill out where it says "nothing".
I am trying to set the print area based on cell values, but I keep getting errors when running the macro. It fails where I have highlighted, but rc.Value shows as the proper number.
[Code] ....
I'm trying to get this macro to work; so that when someone hits the ok to print button on a worksheet titled "TOTALS", if cells C18 and C3 don't equal each other it would prompt the user and cancel the print.
View 2 Replies View RelatedI need to have a macro or VB that prints a number of pages based on the value of a cell in the workbook.
Example:
A1 = 155
B1 would divide by 50, print 3 pages where B1 = 50 and then print the 4th page where B1 = 5.
I am trying to find a formula to set the print area to only print rows that contain actual data and ignore the formula.
The spreadsheet is going to be used by multiple users and locked from editing so I have formulas set in column H all the way to row 200 but no data is actually in column H until they enter a date in column B. Since there are formulas in column H when the user tries to print, it is printing all pages even if there is no data.
Here is my formula in H2:H200 =IF(B2="","",SUM(B+14))
I have the following code to print a selection of data which is fine but i need to have in the code a different printer. So, for example my default printer needs to stay the same but when this spreadsheet is open i need the data to be printed to another printer.
View 3 Replies View RelatedOn the attached sheet I would like to set the print range and then print based on 1 cell's valve. F9 is the value I would like to use:
If F9=1 I need it to print A1:M43
If F9=2 I need it to print A1:M87
If F9=3 I need it to print A1:M131 and so on.
There are 20 worksheets in my workbook. For the first ten, I would like to print out the only sheets in which cell E28 = 0. For the last ten, I would like to print out the sheets in which cell T1 = 0. Each sheet has a unique name.
View 9 Replies View RelatedI have someone to setup a macro for me to print from 1 to 100, but I would like to set a criteria print only if the cell(A1) = "A" then run the macro. How can I modify this macro?
For a = 1 To 100
Range("C1").Select
Selection.Copy
Range("B5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Next a
I have a "submit" button macro which user would click after he has finished his input. This macro would update a reference number on the worksheet named "orange" and then print out this worksheet.
My purpose is "orange" is printed out with a reference number.
Below is the 1st code.....
I am trying to copy two cells from one worksheet to another in the same work book based on the value in Column B of one of the sheets. This is just a building block to a larger script I am going to create.
Below is my attempt but I keep getting an error at Range(Cells(x, 3)).Select.