Print Area Range Based Upon Formula
Feb 26, 2012I am trying to dynamically set a print area based upon a formula from the contents of 2 cells. What I need is the print area range to be C1 to Ix, where x is the result of ((A2/B2)+2).
View 2 RepliesI am trying to dynamically set a print area based upon a formula from the contents of 2 cells. What I need is the print area range to be C1 to Ix, where x is the result of ((A2/B2)+2).
View 2 RepliesUsing 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 workbook with multiple sheets that I need to print.
Is there a way to create a fixed print area within which you can mess around with formatting without extending or shrinking the print area?
I have tried adjusting the margins settings so that they are all the same, but this does nothing to keep a fixed print area.
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.
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 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
View 6 Replies View RelatedI 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:
rngUnion.Select
ActiveSheet.PageSetup.PrintArea = ActiveCell. CurrentRegion.Address
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.
Note:
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
End Sub
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 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 want to select a range in a spreadsheet and then set it as the print area. the last column I want to be selected is contains the text data "ABC" in row 1 and is the only column with data "ABC" in row 1. The last row I want to select contains the text data "DEF" in column 1 and is the only row in column 1 containing the data "DEF". Basically I want to select the range [A1:column("ABC")row("DEF")] and then set it as the print area.
View 2 Replies View RelatedHow can I print 2 selected area (highlighted area). I know there is a trick to do that. Right now I can only select (highlight) one area to print, but would like to know how to print 2 or more areas at same time
View 7 Replies View RelatedI just converted from Excel 2003 to 2007 and print previewed a worksheet and find a tiny image with a small portion of the print area. When I look at the sheet in page break preview mode, I see the 8.5 x 11 sheet broken up into approx 77 smaller sheets. When I try to move the page breaks to include the whole sheet it states the change cannot be made as it will result in an image less than 10%. I have attached two images - the first shows the print preview I get, and the second show the multiple pages when I view in page break.
View 4 Replies View Relatedwith 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.
e.g.
header_____header_____header
data_______data_______data
data_______data_______data
data_______data_______data
header_____header_____header
data_______data_______data
data_______data_______data
data_______data_______data
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.
I'm trying to set a variable for a range based on the cells selected. For example, I want variable "myrange" to be set to range("A1:D14") if I click on cell A1 and drag it to D14. So far everything I've tried ends up getting the good old "1004 - Application defined or object defined error".
View 4 Replies View RelatedI'm trying to do this:
Column A, B C
A has lets say 100 elements with certain ratings.
B has has a,b or c for each rating from column A.
C returns a for each rating from column A.
I search for a rating with this formula:
= INDEX(range,MATCH(rating;range,1,1,1))
Now I have the relative position of the rating in that range. Now I want to search for "b" in column B that reflects that rating. For instance:
Columns:
10 a 1
20 c 1
30 b 1
40 c 2
...
Search rating = 40 so C would be the answer.
But in that range A1:B4 I want to search for the position of the last b from column B
I tried this but I can't calculate the ranges:
match("b";b1:b1+x,0))
x= INDEX(a1:a100,MATCH(40;a1:a100,1,1,1))
I have a sheet that will be about 5 pages long if printed. To minimize wasted ink and paper, using VB I would like to be able to have it only print the portion uses (data entered) along with a section at the top and bottom. The section at the top would print on the top of the first page and the section at the bottom would print on the last page.
I know I could record a macro to select an area and print that but it would not do what I am trying to accomplish.
I have an excel sheet with lots of rows (it goes up to BAA) I would like to be able to print certain parts with a VBA
for instance if Sales is selected from a drop down (lets say A1) the macro will print
Area : C7:Z500
Scaling: fit to 1 page
Orientation: landscape
Color: Color
or if Sales next year is selected
Area : C7:D7 AA7:AZ500
Scaling: fit to 1 page
Orientation: landscape
Color: Color
etc....
I use the code below to print a portion of a sheet. My problem is that the area always changes. The $A$476 should be the first cell in that column that contains "HEA" The "536" in $F$536 is the last row that contains data. There are conditional formats all the way down to row 1,000 but not data
Private Sub CommandButton1_Click()
Dim strCurrentPrinter As String, strNetworkPrinter As String
****strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
****If Len(strNetworkPrinter) > 0 Then ' found the network printer
********strCurrentPrinter = Application.ActivePrinter
********' change to the network printer
********Application.ActivePrinter = strNetworkPrinter
********ActiveSheet.PageSetup.PrintArea = "$A$476:$F$536"
********ActiveSheet.PrintOut** 'print something
********' change back to the previously active printer
********Application.ActivePrinter = strCurrentPrinter
********ActiveSheet.PageSetup.PrintArea = ""
****End If
End Sub
Obviously there is a function also that finds the full network printer name, I didn't think it was important, because my issue is the print area. Everything else works fine. If you need it let me know and I will post it.
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
View 4 Replies View RelatedGoal is to select range from active cell ( where coursos is ) to the top of that row. For some reason
ActiveSheet.PageSetup.PrintArea = Range("xey1":ActiveCell())
Does not work?
Making a macro that selects active cells (so anything with text in) and sets that as the print area.
Using the default builder I have:
Range("A1:AA44").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWindow.SmallScroll Down:=30
Range(Selection, Selection.End(xlUp)).Select
Range("A1:AA692").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$AH$692"
[Code]...
Can trim this code with something
Range("any containing data").Select
ActiveSheet.PageSetup.PrintArea = "selection"
copying a document that was made in word into Excel. I set the print area and page size but it seems I can keep adding columns. When I check the print preview it still shows the one page but it appears wider.Will it automatically create a new page if the page size limit is reached?
View 2 Replies View RelatedExcel 2003 used to have a feature where the user can select and set the print area. I do not see this feature in Excel 2007. So, how dow I set the print area in Excel 2007?
View 2 Replies View RelatedI can define a name to calculate the desired Print Area for a page. For example, print_area_notes: =Notes!$A$1:INDEX(Notes!$A:$Z,final_Note,5). I can then use that name when defining the Print Area via Page Setup.
The problem is it calculates the cell range immediately and substitutes that in the Print Area field. When print_area_notes changes the actual Print Area does not. Is there some formula I can enter in Print Area that will allow this value to be set dynamically? I have tried setting Print Area to =indirect("print_area_notes") but it doesn't like that. I could, but prefer not to, write a VBA function to set the Print Area but even then how do I set it to be called automatically? I'd prefer to be able to enter a formula and do it without VBA code because you then have the security issues every time the spreadsheet is opened.
I have 2 codes that set up different "print areas". Every time i run one of the codes the print area doesn't get set unless i run the same code again. So if i run code A which will set the print area with no issues and then right afterwards i run code B then code B's print area won't get set unless i run code B a 2nd time. And if i now i run code A, the same issue happens and the print area to Code A won't get set properly unless i run the code again.
Here is part of the code that discusses the print area:
[Code] .....
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] .....
I'm trying to dynamically set the print area for a given worksheet. I use the code below and it works perfectly when it's executed upon opening the tab; however, the worksheet has filters which may lengthen/shorten the required print area.
Is it possible to execute the code below when the user selects print rather than when opening the tab?
[Code] ......
I'm using Excel 2003.
I have a spreadsheet used for costing jobs giving a detailed breakdown of parts and time. Sometimes the customer requests a copy so I'm creating a macro for my boss that prints the spreadsheet, less the hidden columns that I don't want the customer to see. This I can manage.
My question is this: Is there a way within the macro to set the print area to change to where the last cell is automatically?
Each spreadsheet is a different length dependent upon the work required and setting a larger print area to compensate would use excess paper and ink.
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