Setting Multiple Dynamic Print Ranges

Nov 18, 2008

So I've tried this a few different ways and every time I get the 1004 error: "Unable to set PrintArea property of PageSetup class"

Basically I have a macro that goes through a workbook to hide certain rows and columns based on some user inputs. After doing this I would like to set up appropriate print areas on certain sheets so that when you go to print anything it comes out clean. I thought this would be easy but I'm stuck.

The Plans variable in the code below is an integer from the user input. Think of this code as grabbing two separate boxes and setting them as print areas, which I've know I can do manually because I've tried it.

What's wrong with the following code?? (I've also tried using the union function here, to no avail)

View 6 Replies


ADVERTISEMENT

Dynamic Print Ranges With Multiple Non-contiguous Cells?

Jan 24, 2012

I have a worksheet that has a few ranges and I need a printarea statement that looks like this:

Code:
ActiveSheet.PageSetup.PrintArea = "$A$1:$F$26,$G$1:$L$9,$M$1:$P$16,$Q$1:$S$7"

The above works, but each time I generate this worksheet, the ranges for the last row of each area can be dynamic.

So, I tried something like this:

Code:
Sub setPrtArea()
'set the print area
lr1 = Range("F65536").End(xlUp).Row
rngA = Range("$A$1:$F$" & lr1)
lr2 = Range("L65536").End(xlUp).Row
rngB = Range("$G$1:$L$" & lr2)
lr3 = Range("P65536").End(xlUp).Row
rngC = Range("$M$1:$P$" & lr3)
lr4 = Range("S65536").End(xlUp).Row
rngD = Range("$Q$1:$S$" & lr4)
ActiveSheet.PageSetup.PrintArea = rngA & "," & rngB & "," & rngC & "," & rngD

But, it fails. I have looked through many topics on this subject, but nothing seems to fit my scenario. This will pretty much complete my current project if I get this figured out and can export these print areas to pdf without a bunch of blank pages as I get now with no print area set.

View 9 Replies View Related

Macro To Print Sheets With Value In Cell A1 But Print Dynamic Ranges On Certain Sheet

Sep 24, 2013

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] ....

View 3 Replies View Related

Dynamic Print Ranges & Worksheet BeforePrint Event

Jan 27, 2008

I have a dynamic print range defined as follows:-

=OFFSET(Sheet1!$A$1,0,0,MATCH("PRINT_AREA_ROWS",Sheet1!$A:$A,0),MATCH("PRINT_AREA_COLUMNS",Sheet1!$1:$1,0)), lets say this equates to range("A1:D12")

I also have a workbook beforeprint event defined as follows:-

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.LeftFooter = "Pete"
End Sub

My problem is that after the Print Event has fired , the dynamic range has been converted into a static one i.e range("A1:D12"). I have tried this on all version of Excel from 97 to 2007 and it behaves the same so premably this must be by design rather than a bug?

Am I doing something wrong? What is the work around? I'd rather not have to create the dynamic range within the print event procedure unless I have to as my workbook has many, many tabs!

View 9 Replies View Related

Create User Settable Print Area With Dynamic Ranges

Jan 29, 2007

Once a user of my workbook has input various price levels on the Input Page, the data is sorted on the output page. As the data on the Output Page is quite vast and not all of it is relevant on a particular day, the user is interested in just printing a certain range of data that are in 5 columns. I am trying to figure out how to set up a macro that will allow the user to enter into an Input Box the range to print (ie. Cells C25:G60).

I found one example on this site listed below that allows one to do that but I would like to make it more user friendly. I do not want to make the user have to write out Excel cooridinates. Specifically by allowing the user to input in the Input Box a High price level in Column C and a Low Price level in Column C ; The macro will look in Column C for the highest instance of this High Price and begin the range down to the last instance of the Low Price (there can be several instances of the exact price level.) The macro would then create the print preview of the cells Cxx:Gyy.

Sub SelectPrintArea()
Dim PrintThis As Range
ActiveSheet.PageSetup.PrintArea = ""
Set PrintThis = Application.InputBox _
(Prompt:="Select the Print Range", Title:="Select", Type:=8)
PrintThis.Select
Selection.Name = "NewPrint"
ActiveSheet.PageSetup.PrintArea = "NewPrint"
ActiveSheet.PrintPreview
End Sub

View 9 Replies View Related

Print Multiple Ranges From Multiple Sheets Userform

Jun 16, 2007

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:

Sub Button2_Click()
Sheet7.Activate
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
End With
ActiveSheet.PrintOut
End Sub

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.Activate
'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
End With

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.

View 6 Replies View Related

Macro: Print Ranges From Multiple Sheets

Dec 6, 2006

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).

Sub CommandButton1_Click()
Range("J2").Select
Sheets("AY114").Select
Range("A4:J53").Select
ActiveSheet.PageSetup.PrintArea = "$A$4:$J$53"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWindow.SmallScroll Down:=45
Range("A56:M151").Select
ActiveSheet.PageSetup.PrintArea = "$A$56:$M$151"......................

View 4 Replies View Related

Multiple Dynamic Name Ranges In Same Column

Apr 24, 2007

I have a huge database. The rows are broken up by the groups. The columns are broken up by months, quarters, and totals. All the named ranges are the same exact size because all groups have the same category names and all columns have the same amount of months and quarter columns. So it sort of looks like this

Actual 2006-----------------------------Actual 2007
Group Category Jan Feb Q1 Total-------Group Category Jan Feb Q1 Total
100 Labor Cost 220 130
100 Labor Cost-Expense
Group Category Jan Feb Q1 Total
101 Labor Cost
101 Labor Cost-Expense

Hopefully this gives you a good idea of what the spredsheet format is. Right now I have named ranges for all the groups and years. So the top left name is A06_100, then it goes A06_101, etc. What I'm trying to do is set this up as easy as possible to insert rows in the named ranges and keep the named range, because they are referenced a lot in other worksheets. Also if any columns get added. Basically I want it as user friendly as possible so when people change things it stays together.

View 2 Replies View Related

Multiple Criteria Sum With Dynamic Ranges

Dec 11, 2007

I have a sum part of which is $I$4:$I$500.

The 500 part of the sum is constantly being manually changed using edit replace because of a growing amount of data.

In cell A1 ona another worksheet within the workbook I use the Count function to count the number of rows containing data. This cell is named DataCols

Is it possible to combine $I$ with the named Range DataCols?

I have got this far - ="$I$"&INDIRECT("ColNo") which returns 500 if I remove "&I$"& in front of it.

View 6 Replies View Related

Multiple Dynamic Named Ranges

Mar 19, 2008

I am trying to create a dynamic named range with a sales rotation tracker. Basically, I have a list of leads that come in each week and I add them to the tracker distribute the leads to sales people based on a rotation. I would like to create a dynamic named range for each sales person that will select each sales person's name including the lead information in the row.

I have read all of the dynamic named range information at the link below as well as the advanced dynamic named range page and I can't seem to put my finger on this short of doing it manually.

View 9 Replies View Related

Macro To Print Multiple Named Ranges To Single PDF?

Apr 29, 2013

What I have is a large number of sheets in a workbook (26 to be exact). Each of these sheets has one specific named range. The file itself is quite large so I would like to print these ranges to a single PDF file. I did my best to search for this topic in the forums and while I did find some macros that were close, there was some sort of piece of code missing. Also, will how I list the named ranges determine the order of how they will show up in the PDF File?

View 3 Replies View Related

Print Macro For Multiple Ranges And Graphs On One Worksheet To Separate Pages

Mar 26, 2014

There were 2 macros. One printed all of the defined ranges (40) on separate pages, and the other printed all the graphs ("charts" - 39) on separate pages. I tried to combine the VBA code to print each range and then the corresponding graph. Everything is still on separate pages, but it saved time because I didn't have to collate after printing. It seemed to work. Then I tried figure out if I could print them all to a specific tray of the printer as set in the workbook or as the printer default. Now both the combined macro and the original macro are giving errors.

Is the code I have correct to do what I am trying to do (print each range and then the graph all on separate pages)? Is there any way to put the output tray choice into the macro?

Sub Load_Data_Report()
'
' Load_Data_Report Macro (print all tables & graphs)
' Macro recorded 12/21/00 by xxx
'
' Keyboard Shortcut: Ctrl+j
'

[Code] ........

View 1 Replies View Related

Charting Multiple Dynamic Ranges As Single Continuous Series

Mar 10, 2014

I have a log where I'm recording daily readings of a pipette. Each day three readings are taken and I have each stored as a dynamic range so that I can monitor how in control my process is. However, when I graph it, I would like it to be one continuous line graph (Three readings from day one followed by three readings from day two, etc.). I'm having difficulty doing any sort of combination.

View 7 Replies View Related

Setting Print Area By VBA?

Aug 19, 2014

I have looked for a way to set the print area of a worksheet through vb.

I would like it to find the last row of the worksheet and set it to be printed.

Some of the examples take it beyond the last row of data, because the the code that may be in the empty cells.

HTML Code: [URL] .....

View 2 Replies View Related

Setting Print Area VBA?

Jul 19, 2014

I'm looking for code that would set print area when printing the output of my Macro. Print area will always be the same for all two pages. I need to display first two tables on page one, and the next two on page two. All four tables will always contain the same number of columns and rows. I'm trying to automate this process as much as possible.

View 1 Replies View Related

How To Name A Dynamic Range & Make A Validation List (of 2 Dynamic Ranges)

Dec 22, 2009

I have a range which will change in size & in content, & I want this to be a Named Range at whatever size it is.

Reason I want to is because I want to make a Validation List with this dynamic range. I also want a Validation list which lists the content of 2 or more dynamic ranges which may or may not be on the same worksheet - is this possible?

i.e.
First dynamic range: called "Milestones" at A11
Second dynamic range: called "Activities" at A25
& make a Validation list that will list content of both

View 9 Replies View Related

Page Setting Print Macro

Aug 18, 2006

I have a excel sheet with multiple sheets in it.And I have a VBA macro which split all those sheets into one file each.When I am trying to print one file(SHeet) which has more than 15 columns it is printing in two pages(Width).Is there any code i can use so that when ever i open a file which was split by me and give print command the width should fit to the page and peint.

View 6 Replies View Related

Dynamic Starting Point For Dynamic Named Ranges

Jun 21, 2009

I would like to replace the blue bit of this Dynamic Named Range (DNR) with an INDIRECT formula in order to modify the starting point for the DNR: =OFFSET(DATA!$C$60,0,0,20,1). Unfortunately, I can’t seem to get my INDIRECT formula to work in order to use it to replace the blue bit above: INDIRECT("'"DATA"'!&ADDRESS(MATCH('SHEET1'!AC8,DATA_Date,0)+22,3)"). The orange bit of the formula above returns a value of 60, therefore the ADDRESS formula should return $C$60, that can then feed into the INDIRECT and act as the equivalent of DATA!$C$60. But it doesn’t.

View 2 Replies View Related

Dynamic Range Setting

Oct 22, 2009

This should be easy ... can't figure it out. If I want a formula that wants to perform an action (NPV, but I don't think that matters) on the cell directly above and the next "X" (say 20 cells/years of cash flow) to the right of it, how can I set it up so that I can copy the formula across as well as change "X".

(Obviously, it's easy to select a 20 cell range and copy it across ... but what if I want the length of the range to by dynamic (ie I want to switch to a 40 year NPV instead of a 20 year)?)

View 2 Replies View Related

Setting Same Print Area And Settings Across All Worksheets?

Feb 2, 2014

Is it possible to set the same print area and print settings i.e. Landscape and 1 page tall by 2 pages wide, across all worksheets in an excel file? I have a file with 365 worksheets. They all have the exact same layout and need to be printed off daily. I can set the print settings every day manually but was wondering if there is an easy way to do them all in one go?

View 4 Replies View Related

Setting Ranges For Comparison Operators

Jul 21, 2009

Is it possible to set a range using comparison operators? ie. if a number lies within x and y then such and such happens.

View 6 Replies View Related

Using Named Ranges When Setting Range In VBA?

Oct 13, 2013

Im trying to set a range using a named range and dont know the best way to do this. so far ive got

Set rDataRange = Range(Offset("datastart",1, 0) & ":" & Offset("datastart",LastRow, 0))

datastart is the named range in the sheet and im trying to make a new range that starts 1 row below where datastart is and end where lastrow is. not sure where i messed up on this but i get errors when i try to run this

View 3 Replies View Related

Dynamic Setting Of X Axis Minimum Value?

Jul 7, 2014

I have a graph where dates are shown on the x axis. I would like the date range always to start on the date when I am updating the chart, e.g. sourced from a cell with formula =now().

View 1 Replies View Related

Setting Dynamic Folder Path?

Sep 6, 2013

I made an excel document for my boss with the list of the furniture in an flat that we will rent. The document will be signed by the the guest of the apartment and will be used if anything at the end of the renting period is ruined or is missing. It's kind of insurance. The problem is that next to the cell with the list of furniture I made a list of hyperlink connected to the photos of the furniture. Everything is working on my computer where the photos are in a folder that is contained in "documents" but as soon as I try it in another computer placing the folder again in the document folder it doesn't work. It says "the file is missing". I just realized that I need a dynamic path but today I have to handle the excel file and I don't know how to do it and to change the path of every link with just few clicks I have no time to change photo by photo (there are like 300 pictures).

View 1 Replies View Related

Setting Variable, Discontinuous Print Area In A Macro

May 29, 2009

I need to write a macro to set the print area to the first two columns (A & B), and the last 12 columns (the last column may change). In both cases I need to print all rows (start is row 1, last row is variable). I am trying to achieve something like the "Freeze Pane" effect with the printer. The first two rows contain column headers (dates). The first two columns contain information that needs to be included on the printout, whilst the last 12 columns contain the most recent data.
Various cells withing the selected ranges may be blank, but no row or column will be entirely blank.

View 2 Replies View Related

Excel 2010 :: Setting Up File To Print - Cannot Reopen It

Apr 17, 2013

In Excel 2010 I was working on a file setting it up to print. The file closed somehow and I just cannot reopen it. There are other files in the same folder and they all open normally.

View 4 Replies View Related

Setting Named Ranges (OFFSET/COUNTA)

Oct 19, 2007

I am a novice excel and VBA user, but have been working the past few days on a project to create a data entry form (using Excel 2003 on WinXP). I have the userform created and the textboxes working fine for inputting data into the spreadsheet. I also have comboboxes set up, and if I directly input data into them, they also input that data. So far, so good.

(problem)

Here is my issue: I want the comboboxes to use dynamic / variable ranges, so I have been trying to set up the ranges by defining them as names. I've come across a bunch of examples, but none of them seem to work (all produce an error that the formula is not correct or instead seem to reset the name to just the first cell when I input it).

My sheet is called Dropdown Lists, and there is a column here for each combobox. Each row in a column has the options I'd like used for that combobox. So I am basically trying to name a range as the entries in just one column.

This is what I have been working with most recently in the Name - > Define dialog box that according to everything I read -SHOULD- be working:

=OFFSET('Dropdown Lists'!$A$3,0,0,COUNTA('Dropdown Lists'!$A:$A),1)

This produces an error, that when you hit OK highlights "$A$3" - and if I remove the $ symbols, it skips then to the "$A:$A" until I remove THOSE $ symbols, and then excel will accept it, but when I go to the name, it only highlights one cell. I thought maybe that was OK, but when I tried putting the name into my rowsource, nothing happened - so apparently not.

Questions:

(main question)
- Why will this not input correctly when everything I read suggests this format? Am I not handling the space in the worksheet name correctly (with ' ')? Sometimes excel will automatically add in " " between = and OFFSET and the closing at the end, but this also has not helped. One source I read even recommended taking off the = at the start (also did not help). Am I missing something here?

(follow-up questions)
- Why are you supposed to use "$" before the cell references anyway? I've looked for an answer but haven't found one yet... is that for when you make cell references to cells on an external worksheet?

- What is the "Add" button for on the Name -> Define dialog box? I'm confused to if I am supposed to use this to add the name to the list of defined names, or just hit OK?

- At the bottom of the Name -> Define dialog box is the "Refers To:" field with the formula. On the right of that you can hit a button to go to what seems like another (smaller) formula input box. Why would I ever use that when I could just type it in on the previous box? There is no label for it so I am guessing here - but does it actually do something else (like you need to go to that smaller dialog to input new formulas and the previous box is only for -viewing- formulas, or?)?

View 9 Replies View Related

Setting Column Chart Data Using VBA For Variable Ranges

Mar 10, 2014

I have some code to plot a column chart of data but it isn't working as expecting at the moment. The code is below. The variable binCounter is a count of how many cells in a range that I want to plot on the chart.

However, what I am finding is that the first couple of cells in the range appear as the series name with the rest appearing as the data in the chart. Secondly, the chart appears with the axis labels 1,2,3 etc when I have some custom ones I would prefer to use. How do I go about setting this property, as I can only find options on setting the axis title There is a lot of stuff on XY charts on Google but I can't find much on column charts unfortunately .

VB:
'activate sheet and chart
Worksheets("Home Page").Activate
ActiveSheet.ChartObjects("Histogram").Activate

'set variables for chart
With ActiveChart

[Code] .....

View 1 Replies View Related

Static Ranges And Dynamic Ranges

Feb 26, 2010

definitions for static ranges and dynamic ranges?

View 9 Replies View Related

Print Ranges From Userform

May 19, 2014

I have a number defined print ranges. I wish to create a list of all the named print ranges and then select certain ranges to print in a single document. I have been told can use something called a "userform".

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved