Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Print
I want to put a command button on my excel spreadsheet. I have how many
pages in a cell example in cell AH42 will say 3. How do I tell it to print pages 1-(whatever the number in AH42) is? Thanks Cheyenne |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Print
Something like:
Option Explicit Sub testme() With ActiveSheet .PrintOut from:=1, to:=.Range("ah42").Value, preview:=True End With End Sub You may want to verify that that range holds a nice valid number, too. Chey wrote: I want to put a command button on my excel spreadsheet. I have how many pages in a cell example in cell AH42 will say 3. How do I tell it to print pages 1-(whatever the number in AH42) is? Thanks Cheyenne -- Dave Peterson |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Print
Sub Print_Pages()
Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord Dibben MS Excel MVP On Wed, 11 Apr 2007 11:34:02 -0700, Chey wrote: I want to put a command button on my excel spreadsheet. I have how many pages in a cell example in cell AH42 will say 3. How do I tell it to print pages 1-(whatever the number in AH42) is? Thanks Cheyenne |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Print
Private Sub CommandButton1_Click()
Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub this is what I have but it says compile error expect end sub. Thanks again Cheyenne "Gord Dibben" wrote: Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord Dibben MS Excel MVP On Wed, 11 Apr 2007 11:34:02 -0700, Chey wrote: I want to put a command button on my excel spreadsheet. I have how many pages in a cell example in cell AH42 will say 3. How do I tell it to print pages 1-(whatever the number in AH42) is? Thanks Cheyenne |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Print
Chey
Delete the line Sub Print_Pages. You have wrapped my Sub into a CommandButton Sub. Gord On Wed, 11 Apr 2007 13:16:02 -0700, Chey wrote: Private Sub CommandButton1_Click() Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub this is what I have but it says compile error expect end sub. Thanks again Cheyenne "Gord Dibben" wrote: Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord Dibben MS Excel MVP On Wed, 11 Apr 2007 11:34:02 -0700, Chey wrote: I want to put a command button on my excel spreadsheet. I have how many pages in a cell example in cell AH42 will say 3. How do I tell it to print pages 1-(whatever the number in AH42) is? Thanks Cheyenne |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Print
I hope I don't drive you nuts but I actually wanted to add to this.
I want the button on sheet "Request Form" I want this sheet to print page 1 of 1 and then I want the code you just gave me also that sheet is called "Attendance Sheet" I am I able to do all that or do I need to buttons. "Gord Dibben" wrote: Chey Delete the line Sub Print_Pages. You have wrapped my Sub into a CommandButton Sub. Gord On Wed, 11 Apr 2007 13:16:02 -0700, Chey wrote: Private Sub CommandButton1_Click() Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub this is what I have but it says compile error expect end sub. Thanks again Cheyenne "Gord Dibben" wrote: Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord Dibben MS Excel MVP On Wed, 11 Apr 2007 11:34:02 -0700, Chey wrote: I want to put a command button on my excel spreadsheet. I have how many pages in a cell example in cell AH42 will say 3. How do I tell it to print pages 1-(whatever the number in AH42) is? Thanks Cheyenne |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Print
You could do it all in one macro or two separate macros.
Here is a single macro that prints page 1 of 1 from Request Form then prints the number of pages found in AH42 on Attendance Sheet. Please forgive the "selects". Too busy to correct right now. Private Sub CommandButton1_Click() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") Sheets("Request Form").Select With ActiveSheet.PageSetup ActiveSheet.PrintOut From:=1, To:=1 End With Sheets("Attendance Sheet").Select With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord On Wed, 11 Apr 2007 15:32:02 -0700, Chey wrote: I hope I don't drive you nuts but I actually wanted to add to this. I want the button on sheet "Request Form" I want this sheet to print page 1 of 1 and then I want the code you just gave me also that sheet is called "Attendance Sheet" I am I able to do all that or do I need to buttons. "Gord Dibben" wrote: Chey Delete the line Sub Print_Pages. You have wrapped my Sub into a CommandButton Sub. Gord On Wed, 11 Apr 2007 13:16:02 -0700, Chey wrote: Private Sub CommandButton1_Click() Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub this is what I have but it says compile error expect end sub. Thanks again Cheyenne "Gord Dibben" wrote: Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord Dibben MS Excel MVP On Wed, 11 Apr 2007 11:34:02 -0700, Chey wrote: I want to put a command button on my excel spreadsheet. I have how many pages in a cell example in cell AH42 will say 3. How do I tell it to print pages 1-(whatever the number in AH42) is? Thanks Cheyenne |
#8
Posted to microsoft.public.excel.misc
|
|||
|
|||
Print
So far so good except
ActiveSheet.PrintOut From:=X, To:=y It says is has to be between 1 and some large number. Thanks for your time. "Gord Dibben" wrote: You could do it all in one macro or two separate macros. Here is a single macro that prints page 1 of 1 from Request Form then prints the number of pages found in AH42 on Attendance Sheet. Please forgive the "selects". Too busy to correct right now. Private Sub CommandButton1_Click() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") Sheets("Request Form").Select With ActiveSheet.PageSetup ActiveSheet.PrintOut From:=1, To:=1 End With Sheets("Attendance Sheet").Select With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord On Wed, 11 Apr 2007 15:32:02 -0700, Chey wrote: I hope I don't drive you nuts but I actually wanted to add to this. I want the button on sheet "Request Form" I want this sheet to print page 1 of 1 and then I want the code you just gave me also that sheet is called "Attendance Sheet" I am I able to do all that or do I need to buttons. "Gord Dibben" wrote: Chey Delete the line Sub Print_Pages. You have wrapped my Sub into a CommandButton Sub. Gord On Wed, 11 Apr 2007 13:16:02 -0700, Chey wrote: Private Sub CommandButton1_Click() Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub this is what I have but it says compile error expect end sub. Thanks again Cheyenne "Gord Dibben" wrote: Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord Dibben MS Excel MVP On Wed, 11 Apr 2007 11:34:02 -0700, Chey wrote: I want to put a command button on my excel spreadsheet. I have how many pages in a cell example in cell AH42 will say 3. How do I tell it to print pages 1-(whatever the number in AH42) is? Thanks Cheyenne |
#9
Posted to microsoft.public.excel.misc
|
|||
|
|||
Print
I do not get this message when I test the code.
Maybe change Long to Integer. Gord On Wed, 11 Apr 2007 17:12:02 -0700, Chey wrote: So far so good except ActiveSheet.PrintOut From:=X, To:=y It says is has to be between 1 and some large number. Thanks for your time. "Gord Dibben" wrote: You could do it all in one macro or two separate macros. Here is a single macro that prints page 1 of 1 from Request Form then prints the number of pages found in AH42 on Attendance Sheet. Please forgive the "selects". Too busy to correct right now. Private Sub CommandButton1_Click() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") Sheets("Request Form").Select With ActiveSheet.PageSetup ActiveSheet.PrintOut From:=1, To:=1 End With Sheets("Attendance Sheet").Select With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord On Wed, 11 Apr 2007 15:32:02 -0700, Chey wrote: I hope I don't drive you nuts but I actually wanted to add to this. I want the button on sheet "Request Form" I want this sheet to print page 1 of 1 and then I want the code you just gave me also that sheet is called "Attendance Sheet" I am I able to do all that or do I need to buttons. "Gord Dibben" wrote: Chey Delete the line Sub Print_Pages. You have wrapped my Sub into a CommandButton Sub. Gord On Wed, 11 Apr 2007 13:16:02 -0700, Chey wrote: Private Sub CommandButton1_Click() Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub this is what I have but it says compile error expect end sub. Thanks again Cheyenne "Gord Dibben" wrote: Sub Print_Pages() Dim TotPages As Long Dim x As Long Dim y As Long TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") With ActiveSheet.PageSetup x = 1 y = Range("AH42").Value ActiveSheet.PrintOut From:=x, To:=y End With End Sub Gord Dibben MS Excel MVP On Wed, 11 Apr 2007 11:34:02 -0700, Chey wrote: I want to put a command button on my excel spreadsheet. I have how many pages in a cell example in cell AH42 will say 3. How do I tell it to print pages 1-(whatever the number in AH42) is? Thanks Cheyenne |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Print and Print Preview Graphic Moving Resizing 2007/2003 | Excel Discussion (Misc queries) | |||
cell borders that I create dont show on print preview or print | Excel Discussion (Misc queries) | |||
Pivot Table macro to set print area and print details of drill down data | Excel Discussion (Misc queries) | |||
Active cell counting in particular print page (one sheet having different print area) | Excel Worksheet Functions | |||
How can I print current row in same place on paper but not print surrounding cells??? | New Users to Excel |