Code To Print Ranges Based On A Cell's Valvue

Nov 7, 2009

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

View 3 Replies


ADVERTISEMENT

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

VBA Code For Printing Variable Print Ranges

May 5, 2009

I am trying to write VBA code that will print a print range that is presented in cell F3 on a "Reports" worksheet. The content of F3 will change depending on how many reports the user selects to print. For example, he could select one, two, three reports etc - up to twelve. The cell ranges of each report are named (e.g. Report1, Report2 etc) so that if the user selects to print Reports 1 and 2, the contents of cell F3 are "Report1,Report2". If I replace WhatToPrint with "Report1,Report2" the print macro works.

Sub Macro2()
Dim WhatToPrint As String
WhatToPrint = Sheets("Reports").Cells(3, 6).Value
'sets the variable to equal the contents of cell D3 which contains the formula
'summarising the print ranges I want to print
Sheets("Reports").Cells(3, 6).Select
ActiveCell.FormulaR1C1 = WhatToPrint
' pastes the variable in cell F3 - just to check that it looks like I want it to
Sheets("Reports").PageSetup.PrintArea = WhatToPrint
'uses the variable to set print area - this is where it fails!
'if you replace the variable with the contents of cell F3 the macro will work
ActiveWindow.SelectedSheets.PrintPreview
End Sub

View 3 Replies View Related

Adjusting Code To Use Alternate Cell Ranges

Apr 5, 2009

Here's a nice easy one for anybody whose used excel for more thaan a week unlike me, I'm using the following code to access a popup calendar:

View 2 Replies View Related

Code To Protect And Unprotect Cell Ranges?

Jan 28, 2014

following code so as to have certain cell ranges protected and unprotected USING COMMANDBUTTON/PASSWORD

Code:
Private Sub CommandButton1_Click()
Dim Password As String
JamesPassword = "MyPassword" '

[Code]......

View 8 Replies View Related

Print A Worksheet Based On Value In Another Cell

Jul 18, 2014

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.

View 3 Replies View Related

Print A Report Based On Cell Value

May 25, 2009

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 .

View 2 Replies View Related

Print Based On Cell Contents

Aug 28, 2009

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.

View 3 Replies View Related

Print Area Based Off Cell Value

Apr 3, 2012

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

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

Print Ranges That Change

Sep 14, 2006

I am trying to create a simple code that will allow me to print a range that will change according to the initial inputs. The columns will never change, however the rows will.

So far I have:

Sub PrintLog()
Dim Printer As Range
Set Printer = ActiveSheet.Range("a9", Range("e65536").End(xlUp))
Printer
End Sub

View 4 Replies View Related

Print Named Ranges ..

Feb 16, 2007

I want to create a very simple macro to print some ranges that I have defined in my workbook. The ranges are as follows:

Note: Each of these ranges is in a different worksheet named Cons_Summ, Esky_Summ, Indy_Summ, and Gfld_Summ respectively.

To be printed in portrait view:
- Cons_Summ_IS
- Esky_Summ_IS
- Indy_Summ_IS
- Gfld_Summ_IS

To be printed in landscape view:
- Cons_Summ_OH
- Esky_Summ_OH
- Indy_Summ_OH
- Gfld_Summ_OH

I just want to create a macro so I can run it and it will print all of the ranges listed above with the proper orientation. Nothing special, each range must fit on 1 page x 1 page.

View 7 Replies View Related

Excel 2010 :: Display Cell Ranges From Multiple Locations Based On 2 Cell Values?

Jun 4, 2013

I need to display a set of cells based on the value of two drop down cells i have. As I am not very good at english and worse at explinations, I'll try via screen shots...

I have two dropdowns (C4 and C6) that will indicate what table to use (Second sheet / screenshot). I want that "table" to display in the yellow box on the first page. To complicate matters, some options do not have a CLA option - those starting with X. As there are 24 different outcomes and each is 3x9 if/then statements just dont seem to cut it.

P.S. I have excel 2010 and windows 7

View 1 Replies View Related

Vb Code To Set Print Area And Print Out

Aug 24, 2007

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

View 9 Replies View Related

Set Print Area Based On Cell Values?

Mar 12, 2014

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

View 4 Replies View Related

Cancel Print Based On Two Cell Values

Mar 12, 2009

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 Related

Macro To Set Print Area Based On Cell Value(s)

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

Print Macro Based On Cell Values

Jul 3, 2014

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.

View 4 Replies View Related

Print Number Of Pages Based Cell Value

Nov 21, 2006

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

View 2 Replies View Related

Coding Non Contiguous Print Ranges

Dec 28, 2009

What is the best way to declare non contiguos print ranges?

For instance I have the following
Sheets("Report").Range("C17:C33").Copy
But I want to add other print ranges like J5:K5

View 9 Replies View Related

Non-Continuous Range In Event Code: Show A UserForm When A Cell In 1 Of 31 Named Ranges Is Selected

Nov 7, 2006

I am using the following Selection_Change Event to show a UserForm when a cell in 1 of 31 named ranges is selected.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Dim i As Long

For i = 1 To 31
If Not Intersect(Target, Range("StatPost" & i)) Is Nothing And Target.Value = "" Then
If Target.Offset(0, -8).Value = "" Or Target.Offset(0, -7).Value = "" Or Target.Offset(0, -6).Value = "" Or Target.Offset(0, -5).Value = "" Or Target.Offset(0, -3).Value = "" Or Target.Offset(0, -2).Value = "" Or Target.Offset(0, -1).Value = "" Then....................

View 3 Replies View Related

Macro To Print Document Based On Cell Data

Dec 15, 2008

got 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 Replies View Related

Auto Print Based On A Cell Value For Multiple Works

Jun 10, 2009

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 Related

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

Print Named Ranges .. Report Manager

Feb 8, 2008

I am working on building a better report manager using named ranges

1.) Loop through the workbook and find all named ranges
Output the named ranges to a worksheet

2.) Read the values from the worksheet and print each one

Seem simple enough and is really just first step
Would also like to store all print settings next to each named range to be modified by user as needed and used to format report before printing each range as needed

But I'm getting ahead of myself.
First is to print a named range

My code is below
Error msg:

Run Time Error 91
Object variable or With Block Variable Not Set

Debug points here:

Set rngPrint.Name = wsPrnt.Range("B" & lngRows).Value

1. Loop through all named ranges and output to worksheet. This part works fine:

Option Explicit

Sub GetNamedRange()
Dim nName As Name
Dim wb As Workbook
Dim wsPrnt As Worksheet
Dim Row As Long

With Application
. ScreenUpdating = False
.DisplayAlerts = False
.Calculation = xlCalculationManual
End With

View 6 Replies View Related

Dynamic Named Ranges Based On Cell

Sep 9, 2006

I have just started diving into the vast world of dynamic ranges and it's a bit overwelming. I have a dB of sorts that a listbox in a userform fills off of. The dB will be driven by column A and B. Column B are names that are displayed in the listbox. Column A is the class that these names belong to (3 classes). I need to develop dynamically named ranges of Column B based off of Column A. In other words, I need a dynamically named range for all of class1, class2, and class3 in column A to display column B in the listbox on the userform. I have attached an example to clarify the example.

View 6 Replies View Related

Move Ranges To Corresponding Ranges Based On Column Having Data

Oct 25, 2007

I need help creating a macro that will search through my excel spreadsheet and for every instance where column A isn't empty it should cut a range of columns from that row and paste them in a different range of columns in the row before it. It should then delete the row that it cut the columns from and keep searching until it has done this for the whole worksheet. I can modify which range of columns are needed, but it has been so long since I've worked with excel macros that I haven't been able to do it.

View 5 Replies View Related

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







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