Vba: Set Print Format Across Multiple Sheets
I'm trying to write a macro to select all the Sheets in a Workbook, and set some properties [Auto ColumnWidths, Landscape, and Fit to 1 page wide] for all of them.
I don't know the names of the sheets, nor how many there will be - this part is tagged on the end of a long macro that creates new files and pastes various data into them. The code below only seems to work on the Active sheet - not any of the others selected. Curiously, I can set a specific column width for all sheets, but not Auto Widths.
.PrintTitleRows = "$1:$1"
.Orientation = xlLandscape
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
ActiveWindow.Zoom = 80 ' This line works!
Selection.RowHeight = 13.5
Selection.ColumnWidth = 34 ' This line works
View Complete Thread with Replies
Related Forum Messages:
Vba To Print Multiple Sheets
I've been feverishly searching for a pre-existing macro to print specific sheets assigned manually by the macro to the windows default printer (or better still bring up the printer dialog box and you can select which printer!)
The macro is attached to an image on Sheet 3 called "Details"
The respective sheets I want to print in succession are Sheet 2 "Letter Of Estimation", Sheet 6 "Labour & Equipment SOR" and Sheet 7 "Labour Only SOR".
Can anyone help me with this please? I've been searching for a while and come up with various bits of code that perform intricate loops based on user input, and other unrelated tasks I can't seem to ween out of the code by myself.
Vba To Set Print Area
Looking for a macro that will set the print area on an accounts spreadsheet to the last non blank row, bearing in mind that all the rows contain formulas, have tried some macros but they assume the cells with formulas in them are non blank
Print Multiple Ranges From Multiple Sheets Userform
I inherited a spreadsheet that had an userform where the user checked off which 'pages' he wanted to print. The Ok button routine used if statements to run a routine for each 'page.' Here's an example of the original code for one page:
Run "HorizontalPrintStuff" 'generic landscape pagesetup
With ActiveSheet.PageSetup 'specific pageset settings
.RightFooter = " Construction Assumptions"
.PrintArea = "CONSTRUCTION" 'the named range to print
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1 'this changes depending upon the page selected
The problem was it printed each page as a separate print job; and if you print to adobe, you get serveral files, not one file. That and it took a long time to run.
So I tried a different tack. If the checkboxes has true, then the printarea is set to that named range. If there were more than one named range on a sheet to be printed, I consolidated them. I did this with a bunch of if statements - very cumbersome.
'Sheet3.ResetAllPageBreaks 'disabled due to errors
Run "HorizontalPrintStuff" 'generic landscape pagesetup
With ActiveSheet.PageSetup 'specific pageset settings
.PrintArea = "DEVBGTALL" 'the named range to print
.FitToPagesWide = 4 'this changes depending upon the
.FitToPagesTall = 1
I haven't shown all the code cause it goes on for 12 sheets containing 16 different printareas.
My current muck ups are .....
1) it prints every printarea/named range on a given sheet (I took out all the if statements trying to debug everything.) Is there another conditional argument that allows for multiple 'trues'?
2) the pagebreaks in printarea/named ranges that are multiple pages (like a 48 month schedule) won't stay set. I've tried both VPageBreaks(3).Location:= and .VPageBreaks.Add Before:=
3) the Sheet1.select false argument is always adding a random sheet to the end of the print job. Don't know why.
I can do all this in a recorded macro, just not the selection userform. I've thought about copying to another sheet or hiding columns and rows then printing, but that seems just as cumbersome.
To recap, i want to print out, as one print job, multiple printareas from mulitple sheets, based upon checkbox selection on an userform.
Repeating Multiple Cells A Set Number Of Times To Print Labels
I have a form that users will fill in, and I need to print a set number of labels (all identical) based on the info that is entered.
I have the form set up with data validation and indirect references(Lists on a separate sheet)
User enters in:
Number of items
From there I have a separate set of cells that reference the above info formated to how I want the label to appear when printed.
Now, I need to repeat that label the set number of times (# entered in as "number if items") in a label sort of format (not sure if a mail merge will work for this??)
Then, print off and stick identical labels onto each part that is manufactured per PO/Date etc.
Print Multiple Sheets At Once
I have a workbook consisting of about 20 worksheets. I have VBA code that prints any sheet that is used but skips any pages that are not used. This works fine but if there are more than one user printing sheets at the same time on our network printer, the pages get all mixed together and they have to pick through the stack to find their pages. Is there a way that the used pages can be assembled and then all printed as one printjob so that each users pages will all print together simplifying the sorting process.
VBA - Adding Border Line To Bottom Row Of Set Print Area
I am using the following macro to set print area which I found on the net. I am trying to modify it as I would also like to place a border line on the bottom row but cant find anything to assist me despite searching through several threads.
Dim myrange As String
myrange = .Find(What:="*", After:=.Range("A1"), LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Address
ActiveSheet.PageSetup.PrintArea = "$K$1:" & myrange
Macro: Print Ranges From Multiple Sheets
I am trying to write what I thought would be a simple macro to print out specific areas of my worksheets. I have shown the code below; the line causing the problem I have highlighted in RED. I am getting the following error message: "Select method of range class failed".
Reading other posts here. I think this may have something to do with the macro being assigned to a command button in one worksheet (AY114) and I am trying to get the macro to run on both the worksheet that the command button is in (AY114) as well as another worksheet (AY062).
ActiveSheet.PageSetup.PrintArea = "$A$4:$J$53"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveSheet.PageSetup.PrintArea = "$A$56:$M$151"......................
Print Multiple Sheets Based On Criteria
I am trying to find a way to select and print multiple sheets based on a criteria or a list. I have a large worksheet with many sheets. Each sheet falls into one of three categories, and I want to be able to automatically print all tabs in each category. I have all of the sheets rolled up into a summary where I have access to all of the sheet name and print criteria.
Transferring Print Format Info Via VBA
I am using VBA to copy and paste multiple sheets from one workbook to another. The workbook where the sheets are being pasted has no prior formatting. I want to transfer the *print* formats from the first to the second sheet via VBA. One key thing to note is that the print formats are constantly being changed in the first workbook. So I think I need code to "grab" the formats, then transfer them to the second workbook.
Import, Format, Convert, Print VBA Module
I was wondering if its possible to build a module that would do the following: a) import a txt file to excel formatting it as text.
b) then in column D would remove the preceding space.
c) then convert data in D according to a separately kept Conversion table (or conversion table could be integrated into the code) and print conversion results into column J.
d) the last step is to print/copy columns A and J so that it looks like the final table in Sheet2.
Here are files attached.
To summarize I need to go from a txt file like the one attached and arrive at the table in Sheet2 of xls file attached.
Format Multiple Sheets At Once
I have 14 worksheets in a workbook.
All sheets are identical in that they have the same headings within the same range.
I want to apply formatting (bold some text, apply borders, center, etc.), but to all the sheets at once. I know I can do this with a simple loop, but I was wondering if there is a more efficient way of doing it.
I've been playing with
sheet( array(sheet1.name, sheet2.name))
I don't think I have correct syntax or use using the the above.
I tried coding what I would do if I was performing this manually, which is to select all the sheets and apply the formatting to sheet1. Then all the sheets would have the formatting.
Vb Code To Set Print Area And Print Out
with creating vb code that will select certain rows in a spreadsheet, set the print area to those rows and print them out, and then reset the print area back to default.
The data is all on one sheet, but is split into 5 different areas, each below the next, with the column headers at the top of each.
and so on. At the press of a button it'll set the print area to the first section and print (the section includes the headers as well as the data). Then at the press of another button it'll set the print area to the next section. There could be any amount of rows of data in each section so it needs to cope with that.
Copy & Append To Report, Rows From Multiple Sheets If Any Cell Meets Format Color
I've seen a few threads on here about this issue but none of them do quite what I am looking for. I'd like for a single page "report" to be created when a user presses a button (which runs a macro, of course) The macro should be able to run through certain named sheets (even if hidden) and if a cell in any row is red within a sheet then the entire row or rows that meet the criteria should be copied and pasted into the Report sheet.
On the report sheet, for each sheet that has had rows that were copied, I'd like to have the name of the sheet as the header above the pasted rows so that the user knows which sheet the data came from. Any sheet that doesn't have red cells would be excluded from the report. I've attached a sample file but had to limit the number of sheets because of Orgrid's file size limit. Hopefully, you'll see what I am getting at here.
Running Same VBA Over Multiple Sheets
I have some code which I want to run on all apart from one sheet called 'List'. At the moment I am selecting each sheet before running code for the specified sheet. This doesn't allow for any sheet name changes etc. or additional sheets. Is there a quicker way of doing this rather than having a sub to manually select each sheet?
Here is an example of my code for a button on the sheet called 'List'. The only thing Sheet1, Sheet2 does in this code is select that sheet.
Vlookup In Vba Over Multiple Sheets
I have made a spreasheet with 4 sheets. In the 4th sheet are 3 columns:
There is a button on the first sheet, which when clicked produces an input box. I need the value in the Input box to return which zone that country is in based on the value of the Input Box. E.g. France to return Europe in a message box.
VBA Code To Unlock Multiple Sheets
How I can unlock a range of sheets that are password protected in my workbook.
I have 20 identical sheets one for each department which are protected by the same password.
It would be nice if I could rapidly lock and unlock these sheets.
What I need a set rng command in conjunction with a For Next loop?
Modify ComandButton VBA In Multiple Sheets
I've been successfully using a for loop method to make minor changes to formulas or formatting in multiple sheets within the same workbook.
I would like to update a standard button I have in each sheet. This button jumps the user to the 'dashboard' sheet.
Now I want to add a functionality to the button which makes it input the refrence sheet name into a cell in the 'dashboard' sheet. Is there a way I can make a VBA macro to edit the code in multiple sheets? I'd love to not do this manually for 100 sheets!
Example of my for loop:
VBA Consolidating Multiple Sheets In A Pivot Table
I got a brilliant bit of code (which works perfectly) from Bill Jelens "Excel Gurus gone Wild" which loops through all worksheets in the activeworkbook and consolidates these worksheets into one pivot table, this example creates the pivot in a new workbook, what I would really like to do is add a new sheet and create the pivot in the active workbook where I am pulling the data from can anybody help me to modify the code?
I have not added the code yet to generate the pivot
Dim i As Long
Dim arSQL() As String
Dim objPivotCache As PivotCache
Dim objRS As Object
Dim wbkNew As Workbook
Dim wks As Worksheet
ReDim arSQL(1 To .Worksheets.Count)
For Each wks In .Worksheets
Do Until wks.Name = ""..............
Copying Sheets Multiple Times Using VBA Causes Error
There is a Microsoft VBA bug currently outstanding where if your VBA replicates a sheet too many times, it throws a run-time error. I read MS' statement that, to get around this problem, what one can do is to save and close the file, and re-open the file once in a while.
Doing this certainly helped, where it used to crash after copying only a few times and now it goes on until 40 ~ 50 times. But it still crashes. Has anybody been able to get around this problem? Currently I am having VBA save, close and re-open the file every 7 or 8 times or so...
Print Multiple Pages With Single Print Job
I have a spreadsheet with 28 visible tabs. When I select all tabs and print, I get 3 cover (or banner) pages...I like having the first banner page, but the other two are in the middle of my report. I assume excel is sending 3 print jobs and I'm not sure why.
I've seen a couple of posts regarding this issue when using VBA, but I'm not using VBA...just selecting all the sheets and sending a single print job, but get 3 banner pages.
VBA Select Multiple Sheets Of Varied/Changing Sheet Names
How can I select sheets in a workbook based on the premise that the sheetname does not have the letter "Q" in it? New to forum, so apologies if format is not kosher.
I have a group of 50+ workbooks which are all set up in the following format:
-Contains 30+ sheets.
-Sheet names are varied, but follow a pattern. I try to keep the sheet names consistant on all workbooks so that it is easier to reference, but other users make this impossible.
-However, I managed to keep two things consistant: There are two categories of sheets. In one group all sheetnames have a "Q" in them and in the other group all sheetnames DON'T have a "Q" in them.
Here is my problem: I need to run a macro to perform retative tasks on the GROUP OF SHEETS WITHOUT A "Q". To begin the macro I need to select these sheets and copy them to a new workbook, but since the actual sheetnames are varied, I am having trouble coming up with a flexible way of selecting sheets. The closest I have come is using a IF ... LIKE ... THEN statement, but I can only get it to work to select the sheets with a "Q" in the name and not the opposite.
Print Multiple Worksheets As 1 Print Job
I'm using VBA code to select several worksheets at once, and print them. The code runs fine, but the result is multiple print jobs, not one job. This is OK when printing to the printer...but undesireable if you want to print to a pdf file, for example.
I've searched the site and found some references to this possibly being an excel problem. Is that true?
I've also checked the page setup setting to make sure that the print resolutions are all the same...that doesn't appear to be the problem either.
Set Print Defaults
I want "Print what" >> "Selection" (instead of Active Sheet) to be selected by default in the print dialog when I press Ctrl+P. How to do it?
See the image if you don't understand which dialog I'm referring to: http://dl.getdropbox.com/u/872430/print_5.gif
My second question is actually answered in a very old thread. I want to know if there is an alternate way or if the answer in old thread is still valid.
The question is "how to set default paper size?"
The answer given in the old thread (http://forums.pcworld.co.nz/showthread.php?t=28637) is by going to Control Panel and changing printer settings. Since, Excel often shows only "blank" (with a dropdown containing the various paper sizes) against "paper size",
Set To Print One Page
How can I set a workbook to only print the first page without printing it? I want to apply it to a folder full of xls workbooks so whenever a user opens one to print, they can just hit print.
I have tried:
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
but it sends the file to the printer. I do not want to have to use a macro in each file, I just want to use an existing xls workbook to apply the settings to many other xls workbooks.
Using Macro To Set Print Area
My macro selects cells containing data - then i want the macro to set the print area to those selected cells - works fine - but the selected cells won't be the same each time i run the macro. Here's how it looks now:
ActiveSheet.PageSetup.PrintArea = "$A$1:$M$76"
The next time i run the macro the selected cells won't be A1:M76 - how do i have the macro set the print area to whatever is selected?
How To Auto Set Print Area
if there is a way with functions or code to automatically set the print area. I would like to have it set to start at A1 and print to column G & the first ROW with a zero value in column F.
The ROW in which the first zero value appears will be the only variable. It will
always be column G.
Set Print Area Through Code
I am having trouble setting print area on rows that can vary from 100 to 6000 rows. This code works good except that the print area cuts off the last row of data every time. "AreaBegin"=row 6 and "AreaEnd" = to last row after a set number of rows have been inserted based on a counter.
Basically how do I get this code to capture the last row for print area?
ActiveSheet.PageSetup.PrintArea = Range("AreaBegin", Range("AreaEnd").End(xlUp)).Address
Set Print Settings Per Worksheet
At my company we need to print our workbooks containing 3 to 24 worksheets. The first page should be printed on different paper than the other pages. From various forums I gathered that it's not possible to set the papertray using vba. Those forums suggest 3 things: 1. Windows Api functions (don't work at our company(security)), 2. SendKeys (don't work because of different printers, office versions and future-proofness) and 3.
Define printerdrivers per tray.
This last I did, so there are printerdrivers for tray3 and tray4.
With the following code I try to print the workbook:
Public Sub printSheets(strP1 As String, strP2 As String)
Dim curPrinter As String, firstPage As Worksheet, otherSheet As Worksheet, x As Integer
Set firstPage = Application. ActiveWorkbook.Sheets(1)
curPrinter = Application.ActivePrinter
Application.ActivePrinter = strP1
The problem: The sheets are sent to the printers specified as strP1 and strP2, but the tray-settings from these printers are "overruled" by Excel; they are printed from the papertray that was the default of the printer when Excel was started.
Also, using the default printer dialog from Excel has the same problem; when the (windows-)default printer is Tray3 then all the pages come from there, even when printer Tray4 is selected as the printer. In Word or Acrobat etc the prints come from the right tray.
Set Print Area By Month
I'm trying to set-up the print area for my actual & Forecast. I have two years of data from A1 to U735, dates are in column B. Is it possible with a macro to set up the print area for each Month?
Set Print Orientation On All Worksheets
how would I change the orientation on ALL my worksheets, I'm saying every single one, imagine I got like 100 for the purpose of this excercise (sorry I'm not trying to make this harder, it's just there's always that one guy that'll come on and say 'Go to Print Print Preview, then click on Setup' or something like that.
So yeah, that's pretty much the question that I have for you brainaics:
How do I change the printer orientation setting to landscape on all worksheets (maybe a loop?).
Set Print Area To Used Cells
I am trying to write a macro that will allow the user to print out the sheet from the beginning to the last used row. The catch is that I have formats and formulas all the way to the end (A1:O319). My basic format is a frozen Pane (for a header and summary) from A1:O18, then the user inputs their data starting on B19. The columns never change, and the rows will be variable. I tried a dynamic range to no avail, and have most recently tried this
Dim Rng, cell As Range
Set myrange = Range("A320").End(xlUp)
Set Rng = Range("A1:" & myrange.Address)
For Each cell In Rng
If cell = "" Then
myrange = cell.Address
ActiveSheet.PageSetup.PrintArea = "$A$1:O" & cell.Row
My next plan would be to write to check to see the last used cell in column B, since that cell has only formating, no formula, and is a required entry cell
Set Print From First Column To Last Data Row
i need a macro that will set print from A1 to H (last data row) if age entries in col h is >=5, i dont want to print data below this age criteria
Over2day CDEFGH6Value DateEntry DateTypeAmountCCYAge71-Oct-075-Dec-08LDR2,203.67USD729819-Nov-075-Dec-08LCR200.00USD680924-Jun-0817-Dec-08SCR2,001.38USD462 Excel tables to the web >> Excel Jeanie HTML 4
Set Print Area Of Dynamic Range
I have a sheet with a top portion like a fax cover letter.
Starting at row 17 I merged from B thru L.
This is where the user will type in a message.
The message can extend several pages long, so I merged about 100 rows same as 17.
My sheet only will extend to column N.
There may be instances where the user may leave several rows blank in between what they type.
I am looking for a way to set the print area from A1 to the last row of data and not the last row with formatting.
I have a command button the user is supposed to click when they want to print the sheet.
This is acceptable, but if there was a way around that it would be better.
I do have code in the sheet that will automatically adjust the row height in the merged cells if the data gets too wide. I do not want to upset that.
I have just recently started to learn VBA, so my knowledge of the various commands and syntax is limited.
This is what I have right now that doesn't work.
Private Sub CommandButton2_Click()
Dim LastCell, DataCells As Range
Dim LastDataRow As Integer
Set LastCell = ActiveSheet.Cells.SpecialCells(xlLastCell)
Set DataCells = ActiveSheet.Cells.SpecialCells(xlconstants)
LastDataRow = DataCells.Cells(DataCells.Cells.Count).Row
ActiveSheet.PageSetup.PrintArea = Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(LastDataRow, LastCell.Column)).Address
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Set Print Area From Selected Range
I have some code which selected a certain amount of columns depending on
whether they contain values or not. Once I have this range set and I select
it I want to set this as the print area. I am not quite sure how to do
this. for example I tried:
ActiveSheet.PageSetup.PrintArea = ActiveCell. CurrentRegion.Address
Set Print Area Based On Sort
I have a worksheet which contains data for 6 different groups. I have a sort macro already that sorts them into groups (group 1, group 2, etc.) What I want to do know is set the Print Area so I can just print each group individually with a button("print group 1", etc.)
The worksheet is set up as follows:
Columns B-H are the data I want to have printed. The number of rows is different for each group. I want to set the Print Area based on Column H. So, if H=1, set the Print Area for Columns B-H and all rows that have H=1. This seems like it should be simple enough, but I haven't quite been able to put the pieces together yet.
Set Print Area Based On A Condition
I have a worksheet named "TQUOTE" with the print area defined as A1:E:286 resulting in 5 pages printing ,however if there are only 3 pages of data I will be left with 2 blank pages being printed. (along with the header rows which are set to repeat for each page ). I should mention this worksheet is included in a list of sheets to print based on the response to a user form. Would it be possible to have the print area change based on the an empty cell that related to the next page break? eg. If the page break for page 1 ends at row 55, if a cell in row 56 were empty then set the print area to be A1:E55 If the page break for page 2 ends at row 85, if a cell in row 86 were empty then set the print area to be A1:E85 and so on ?? I do not have the skills yet to write this macro , and i bow to thiose
Set Print Area From Dropdown List
Is it possible to set a print area and then actually print it according to what is chosen from a dropdown list ?
If 'Print area 1' is chosen, it selects A5:D50 & A5:L50 and then prints
If 'Print area 2' is chosen, it selects A5:D50 & M5:S50 and then prints
Macro To Set Print Area W/o Hidden Rows
We run a small gardening shop and use a simple spreadsheet to track of various things.
Row A contains headers, with the data following in the rows underneath. This table is now quite large, and we therefore hide 600 or so rows so that only rows with data from the last week is shown. We often need to print this for easy reference. I currently do this by highlighting the area I want and setting it as print area. The print therefore doesn't include hidden cells, which is what I need.
The problem we have, therefore, is that we have to manually select this print area each time. My experience with macros is VERY limited, to the point where I can record one which will select the print area and print. However, as the list gets longer and more rows are hidden the range obviously needs to change, and my simple macro will not keep up.
So my question is as follows. Is there a simple macro I could write to assign to a button that could "keep up" with the moving range? So either it always prints the header row and the, for example, 50 rows beneath (exlcuding the hidden ones), or, even better, it prints the header row and all rows with data in them that are relevant to the last week. Each row has a cell for the date it concerns so assume this may be possible?