• 0

Solved I Want To Print an Excel Spreadsheet Using a Print Button.

  • 0

I have two worksheets in my workbook. I want to create a “Print” button on Worksheet 1 (the worksheet that I use to enter data) that will print Worksheet 2.

I know how to create a print “button” on my Worksheet 1, but I have no idea how to write the code to print Worksheet 2.

I do not want the computer screen to change from Worksheet 1 upon execution of the print command.

Also, I would want to know how to enable the macro.

If there is someone who can help a guy who has no knowledge of VB programming, I’d appreciate it. Thank you for any help you can be.


1 Answer

  1. Hi,

    ok firstly to enable macros here is what you need to do,

    1) enable the Developer tab – to do this click on file
    2) click on options
    3) click on customize ribbon
    4) tick the little box on the right that says ‘developer’ then click ok

    now at the top of your worksheet you will have a new tab called developer?

    1) click the developer tab
    2) click the yello triangle which says ‘Macro security’
    3) now you can select one of two options
    a) disable all macro with notification
    b) enable all macros (not recommended……)

    i have mine set to enable all macros (not recommended……..) however you can selec the other if you wish, but be warned that if you ever get any dodgy macros from the web or someone else it could harm you machine.

    close excel and reopen it. if you chose the first option it will now show you a yellow bar going across the top of excel, with a button called enable content, click this and macros will be enabled. however if you chose the second option macros will be abled automatically.

    Now to add the button

    1) click the developer tab
    2) click insert, now under the ActivX group select the command button andplace it on your workheet

    3) now double click this button and you will be taken to the VBA consle, you will see the code

    Private Sub CommandButton1_Click()


    End Sub

    now go back to your worksheet, still under the developer tab, you will see a button called ‘Design Mode’ click on it, this will enable your button. click the button and see what happens.

    what you will need to do is, paste the code i gave you above between this code, like this

    Private Sub CommandButton1_Click()

    End Sub

    • 0