User Defined Print Area Macro
Jun 25, 2008
I am looking to create a macro that will ask the user to define the row number of the beginning and ending locations that they would like to print. The columns are fixed in that the first starting row will be from column A and the ending row will be column M.
I have built a pipe tally used in the oilfield that keeps track of large amounts of pipe figures but very often is the case that there is the need to print a section of the tally data in reference to a certain depth. With the vast knowledge base located here I was able to build the first macro that prints the whole active tally but now I need something more refined.
Below is one of the copies of the macro that I was trying to get to work and it is missing a couple of things but the most important part shows up and that is how to get the inputbox variables into the defined print area.
Sub TallyVariable()
Dim StartRow As String
Dim EndRow As String
StartRow = InputBox("Please Enter Starting Row you would like to print")
EndRow = InputBox("Please Enter Last Row you would like to print")
ActiveSheet.PageSetup.PrintArea = "A" & StartRow.Address:"M" & EndRow.Address
End Sub
View 9 Replies
ADVERTISEMENT
Feb 25, 2009
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 Related
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
Feb 12, 2013
I 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.
View 1 Replies
View Related
Jul 20, 2007
Is there a macro that can automatically set the print area by determining what the used range is. For example, If P96 is my last used cell, I would want a1: P96 as my print area.
View 9 Replies
View Related
Oct 11, 2007
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:
Range("A1:M1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
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?
View 9 Replies
View Related
Apr 10, 2009
I am looking to set the print area with a macro, below is what I had hoped would work. It does not. I get unable to get Vlookup property of worksheetFunction class error.
Sub Printzed()
Start = Range("C6").Address
Finish = Res = Application.WorksheetFunction.VLookup(I5, Range("prlu"), 2).Address
myPrintArea = Start & ":" & Finish
ActiveSheet.PageSetup.PrintArea = myPrintArea
End Sub
View 9 Replies
View Related
Mar 18, 2009
I have a document which will require signatures after printed and want to keep the signature portion at the bottom of the page (currently rows 102-104). The problem is that the document will not need to be that long for every person and was wondering if it would be possible to have a macro that checks (C7:C:100), stops printing when it reaches the blank cells, and then prints those last 2 rows?
View 8 Replies
View Related
Jun 13, 2009
The macro below works perfectly except for one problem. I only want it
to set the print area from Column A - Column M . It currently selects data i have in Columns N and beyond and i do not need that to print. From A - M is 13 columns.
View 4 Replies
View Related
Mar 15, 2009
I need a macro to select the area within the blue invoice sheet box, so everything within the blue invoice sheet box is selected , and then the selection should be printed. I will have hundreds of these invoice slips made, right below each other, i was wondering once this is done, is there an easier way to to have each invoice selected, instead of making a custom button for each sheet ( which selects just that invoice , and prints that selection ).
( Column m through v, starting at row 2 stoping at row 68, is the selection required in this example, everythign within the blue box. ).
View 13 Replies
View Related
Dec 8, 2011
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.
View 1 Replies
View Related
Apr 2, 2014
My macro "prints" (saves) my sheet as Pdf-file.
I wish to improve this such as print/save is based on the active area I choose at the time.
Now I must hide a lot of columns (show only the ones I will print) before "printing":
Columns("A:Z").Select
ActiveSheet.PageSetup.PrintArea = "$A:$Z"
I just want to select some columns and set this range as a print.setup area.
View 2 Replies
View Related
May 29, 2014
I have a report that has a set template except that the number of columns change.
I have 3 rectangular shapes with text boxes inside each rectangle. The Shapes take up space vertically between row 8 and 15. In some reports the columns will change, the size of columns might change due to longer text. Is there a macro that will select all the shapes and text boxes and center them column wise between the print area?
View 1 Replies
View Related
Jun 28, 2008
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?
View 9 Replies
View Related
Oct 9, 2012
I have recorded the following marco and it works fine. I would like to modify it so the user would highlight a range of cells rather than have the fixed area :
"'ConsExecProp@20120920'!R4C5:R113C21"
What code lines would need to be added?
Application.Goto Reference:="R4C5"
ActiveWorkbook.PivotCaches.Create(SourceType:=xlConsolidation, SourceData:= _
Array("'ConsExecProp@20120920'!R4C5:R113C21"), Version:=xlPivotTableVersion12 _
[code]....
View 4 Replies
View Related
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
Dec 4, 2012
I would like to send a Excel printing area to a mail recipient by using a macro that:
2) Save the printing area as a pdf - file - use a temporary filename
1) Opens MS Outlook mail
3) Attach the temp-file to the mail
View 6 Replies
View Related
Feb 26, 2009
I am trying to write a macro that publishes the print area as a non-interactive web-page to a file that sits in the same location as the spreadsheet from which the macro is being run.
I am using the the following macro:
View 14 Replies
View Related
Apr 11, 2013
How 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 Related
May 8, 2007
The below macro(found in VBA and MACROS for Excel) works well but I need a few modifications
Option Explicit
Function SortConcat(Rng As Range) As Variant
'Rng —The range of data to be sorted and concatenated.
Dim MySum As String, arr1() As String
Dim j As Integer, i As Integer
Dim cl As Range
Dim concat As Variant
On Error GoTo FuncFail:
'initialize output
SortConcat = 0#
'avoid user issues
If Rng.Count = 0 Then Exit Function
'get range into variant variable holding array
ReDim arr1(1 To Rng.Count)
'fill array
i = 1
1)My array is 128 cells wide(AT3:FQ3) and i get a type mismatch--seems to work well for 36 cells
2) These cells contain dates and numbes---all i want to sort and/or display is the numbers
Note: some numbers are in parenthesis and other are either single or double digits. Example: numbers are (8/8),8,10,(HG6),4,6,etc. And Dates are 04/06 format (no year, and no parenthesis)
3) All empty cells in the array show up in the above SortConcat function as zero, and are un-necessary
4) The final output should be no more than 6 concatenated numbers, so column width is not an issue, and the bubble sort is really not necessary but would be a nice feature
View 9 Replies
View Related
Dec 20, 2007
Trying to put together a macro that looks down active sheet for all cells that contain a value, sets a print area and then prints !
Is this possible?
FYG, I have a column that run from 3 - 2000, which contains a formula, which may produce a value depending on corresponding cells.
I used this code from a post on a similar topic, but excel is complaining code
in bold
Private Sub Print_Area_Click()
Dim lastCell As Range
Set lastCell = Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 0)
Do Until Application.Count(lastCell.EntireRow) 0
Set lastCell = lastCell.Offset(-1, 0)
Loop
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), lastCell).Address
End Sub
View 9 Replies
View Related
Dec 2, 2013
In my spreadsheet, one user defined function i.e. pfizer is there which I want to convert into macro and use it in column H of sheet2 [sheets("sheet2").columns("H:H").select]
What should be the VBA code for this.
when I have started the macro with keyword as application. . the function is not populated.
-->I am able to populate the data with the formula like this = pfizer("I1")
View 1 Replies
View Related
Oct 9, 2012
Trying to convert an Excel 2003 macro to work in Excel 2007.
The problem line is
Dim MyDataObject As DataObject
I suspect the problem is a Missing Reference, but I cannot figure out which one. I have the same ones (in 2007) as 2003 except for one which is not showing
Microsoft Forms 2.0 Object Library
Is this the one it needs? It is called something else in 2007?
The ones I do have ticked are
Visual Basic For Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library
Microsoft ADO Ext. 2.8 for DDL and Security
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Microsoft Scripting Runtime
Microsoft XML v2.6
View 8 Replies
View Related
Jul 29, 2014
I am using Microsoft Excel 2010 and Microsoft VBA 7.0 on my system. I would like to eventually create a PowerPoint and insert charts generated in the Excel workbook. In the meantime, I cannot get the basic PowerPoint created.
The line in red is highlighted blue when the compile error "User-defined type not defined" message box appears.
Public Sub TryAgain() Dim myPowerPoint As PowerPoint.Application
'
' do nothing for now
'End Sub
I have set the references such that Microsoft Project 14.0 Object Library is indeed checked. The Excel file only contains this code in a module. All sheets are blank. Nothing else is written yet.
View 1 Replies
View Related
Nov 28, 2006
I had a working subroutine which I moved to another workbook (rather than linking to it and having both workbooks open at the same time).
Now I get "user-defined type not defined" when it runs. Here is the beginning of the
Global oApp As Object
Sub UpdateForecasts()
Call Update1
Call Update2
End Sub
Sub Update1()
Dim dPath As String
Dim dDest As String
Dim dCondition As String
Dim dName As String
Dim FSO As New FileSystemObject
View 9 Replies
View Related
Nov 7, 2013
I have a worksheet named "ABC". In row 4 of this worksheet, each cell from G to BG is numbered from 1 onwards and each cell has a unique number. I would like to have a macro ask the user through a pop-up question box which column data should be calculated in. For example, if the user types "1" in the question box, the macro will go to column G which has "1" in cell G4 and will select G5 the cell just below the column the user defined and calculate the formula.
View 6 Replies
View Related
Mar 27, 2009
I 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 Related
May 5, 2013
Base 64 Encoding.
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
Are causing the User Defined error, but the same workbook is OK in XP and Win 7.
VB6: Free, Easy and Quick Base64 Encoding and Decoding in Visual Basic [a NonHostile article]
Says you need a reference to Microsoft XML, v2.6 (or later) and the Win8/2010 workbook does have one for Microsoft XML, v6.0
View 1 Replies
View Related
Mar 4, 2010
I am trying to capture with Worksheet Change a command bar action like paste but I am getting an error :
“User-Defined type not defined”
Do I need a library of sort in References ??
Public Sub Right_Click()
Dim oControl As CommandBarControl
For Each oControl In CommandBars("Cell").Controls
Debug.Print oControl.Caption
If oControl.Caption = "&Paste" Then
oControl.OnAction = "MyPaste"
End If
Next oControl
End Sub
View 9 Replies
View Related
Jun 27, 2008
When I try to complile my VBA project, I get the following error "User-defined type not defined" but the compiler doesn't point to any line.
I remember what I did last was to rename a form and a Module, but I replaced their old names in all my code with the new ones ... Does this have anything to do with the error I am getting ?
View 9 Replies
View Related