ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Basic Macro Query (https://www.excelbanter.com/excel-discussion-misc-queries/124554-basic-macro-query.html)

luvthavodka

Basic Macro Query
 
This is my first time trying to write a Macro, but it doesn't seem to work!

I want a "button" on sheet 1 (which is currently just cell D2). On clicking
this button the entire workbook will be printed, except for sheet 1.

So far I have created this code:

Sub Print_All()
'
' Print_All Macro
' Macro recorded 03/01/2007 by Jenny
'

'
Range("D2").Select
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
End Sub

On selecting run macro, this seems to work (although prints sheet 1 also
which I don't want). Nothing happens however when D2 is selected - how do I
make this look like a "button"?


Dave Peterson

Basic Macro Query
 
You can actually place a button on that worksheet.

View|Toolbars|and show Forms
Look for the icon that looks like a button and click on it.
Click on the worksheet and you'll have the topleftcorner--drag to the bottom
left and let go.

You'll be prompted to assign your macro to this new button.

If you're not ready (or want to assign (or reassign it later)), you can
rightclick on that button and choose Assign Macro.

How many sheets are in your workbook?

If the number doesn't change--and the names don't change, you can modify your
code to look like:

Option Explicit
Sub Print_All()
ThisWorkbook.Worksheets(Array("sheet2", "sheet3", "sheet4")).PrintOut _
Copies:=1, Collate:=True, preview:=True
End Sub

Change the names and add more (or subtract if you need less).

And I did a print preview to save paper while testing. Remove that when you're
ready for paper.

luvthavodka wrote:

This is my first time trying to write a Macro, but it doesn't seem to work!

I want a "button" on sheet 1 (which is currently just cell D2). On clicking
this button the entire workbook will be printed, except for sheet 1.

So far I have created this code:

Sub Print_All()
'
' Print_All Macro
' Macro recorded 03/01/2007 by Jenny
'

'
Range("D2").Select
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
End Sub

On selecting run macro, this seems to work (although prints sheet 1 also
which I don't want). Nothing happens however when D2 is selected - how do I
make this look like a "button"?


--

Dave Peterson

Dave Peterson

Basic Macro Query
 
Ps. You can also use a shape from the Drawing toolbar and make it as pretty as
you want--or even a real picture!

Then rightclick on it and assign your macro.

Dave Peterson wrote:

You can actually place a button on that worksheet.

View|Toolbars|and show Forms
Look for the icon that looks like a button and click on it.
Click on the worksheet and you'll have the topleftcorner--drag to the bottom
left and let go.

You'll be prompted to assign your macro to this new button.

If you're not ready (or want to assign (or reassign it later)), you can
rightclick on that button and choose Assign Macro.

How many sheets are in your workbook?

If the number doesn't change--and the names don't change, you can modify your
code to look like:

Option Explicit
Sub Print_All()
ThisWorkbook.Worksheets(Array("sheet2", "sheet3", "sheet4")).PrintOut _
Copies:=1, Collate:=True, preview:=True
End Sub

Change the names and add more (or subtract if you need less).

And I did a print preview to save paper while testing. Remove that when you're
ready for paper.

luvthavodka wrote:

This is my first time trying to write a Macro, but it doesn't seem to work!

I want a "button" on sheet 1 (which is currently just cell D2). On clicking
this button the entire workbook will be printed, except for sheet 1.

So far I have created this code:

Sub Print_All()
'
' Print_All Macro
' Macro recorded 03/01/2007 by Jenny
'

'
Range("D2").Select
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
End Sub

On selecting run macro, this seems to work (although prints sheet 1 also
which I don't want). Nothing happens however when D2 is selected - how do I
make this look like a "button"?


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com