Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Macros
Excel Tutorials For Macros

Print The Current Worksheet in Excel


Bookmark and Share

This free Excel macro will print the current active worksheet in Excel. This means that whatever sheet you are currently viewing will be printed.

This is a good macro to use to ensure that a user is always able to quickly print the current worksheet, even if menu functionality in Excel has been disabled.
Where to install the macro:  Module

Macro to Print The Current Worksheet in Excel

Sub Print_Active_Worksheet()
'This macro prints the active or currently visible worksheet in Excel

ActiveSheet.PrintOut

End Sub


Bookmark and Share


How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

      For Excel Versions Prior to Excel 2007
      Go to Tools > Macros > Visual Basic Editor

      For Excel 2007
      Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

    1. Go to the menu at the top of the window and click Insert > Module
    2. Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
    3. Go to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Go to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
    5. Go to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.



Similar Helpful Excel Resources

Excel Print Current Row Macro Help Please - Excel

View Content
can anyone help? I need to be able to print the current row only with a print button or cell macro.

Thanks in advance

Visual Basic To Print Current Page In Excel - Excel

View Content
Excel 2003

Using Visual Basic I am creating a Project Tracking report using SubTotals. I am using the option "Page Break Between Groups" as the user wants be able to print details for a single Project at a time. Excel doesn't have a "Current" option in the print menu like Word so I don't know how to code to print just the page the user is current on.

I would appreciate any help.

Macro To Automate : A.) Saving Of Open Worksheet As New Excel File, B.)print Command To Print 2 Copies Each With Different Footer, And Some More Queries:) - Excel

View Content
All for the same file
a.) I have an invoice template in one excel file in which I fill in data, out of which some of it auto fills as it is linked to another excel file in which the master data is stored and updated. I wish to edit this invoice "template" (if u may call it that) and once I am done, I wish to click on the Print Macro enabled button that will print 2 copies. (i) 1st Copy with "Customer Copy" and (ii) 2nd Copy with "Merchant Copy" inserted at the bottom
b.)Then I would like to have another Macro enabled button which would:
-Save existing open Worksheet(which has just been printed) as a new Excel file with only the values (no Formalae nor Linking) , retain the exact formatting in the new file (column width etc.), and derive the filename from a cell value from the existing open sheet(edited template) [which will not be present in the new file as it will be out of print area] (the cell is on the far right on the sheet), Close the new file created to a designated folder, and keep the "template" open. Template should be open with the last edited info in order to key in the next chronological invoice no. (Don't know how to automate Invoice Numbers in this scenario, incrementation of the Invoice no. upon the event of Save as New file is daunting!)
c.)I also would like to be able to display numbers in Number Format, but as 001, or 01, or 00009 if that is the way I want to display it. For some reason, in Number format, it will display these values as 1,1 and 9 resp. How do I do that?
d.)Autocomplete! I know I know everyone seems to ask this same question but seriously is it possible? I have drop downs for Names and Products, and one has to keep manually scrolling down, is there a way to atleast be able to put in the first letter and have all records starting with the 1st letter displayed? Or is using the combobox with setting the property to autocomplete the only solution? But I wasn't completely able to do that either!
e.) Well I 've been able to achieve everything in bits and pieces (with my limited VBA knowledge) , but not been able to make all the functionalities work together at once!
Any help would be highly highly appreciated!
Thanks a million for giving it a read atleast ! ( I know I wrote a lot)
Warm Regards,
Sailee

Macro That Will Print Hidden Worksheet Names In A Worksheet In A Workbook Excel 2007 - Excel

View Content
Hello,

Is there a macro that will print hidden worksheet names in workbook in Excel 2007?

thanks

Vba: Excel Form That Updates Current Data On The Same Worksheet - Excel

View Content
Hi there,

I'm a novice with VA and slowly improving my skills.

I've created an Excel VB form that populates fields based on a combo Box (drop down). I can get this form to insert new records, but I can't get it to update an existing record.
Could someone please help me with the code?

The workbook is attached.

There is a similar post, link below:
http://www.excelforum.com/excel-prog...-new-data.html

Below is my code:

Code:

Private Sub cmdSave_Click()

    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("lookuptavernlists")
    
    'find first empty row in database
    iRow = ws.Cells(Rows.Count, 1) _
      .End(xlUp).Offset(1, 0).Row
    
    'copy the data to the database / worksheet
    ws.Cells(iRow, 1).Value = Me.cboTavern.Value
    ws.Cells(iRow, 2).Value = Me.txtFirstname.Value
    ws.Cells(iRow, 3).Value = Me.txtSurname.Value
    ws.Cells(iRow, 4).Value = Me.txtCell.Value
    ws.Cells(iRow, 5).Value = Me.txtSecurityQ.Value
    ws.Cells(iRow, 6).Value = Me.txtSecurityA.Value
    ws.Cells(iRow, 7).Value = Me.Register.Value
    
    'clear the data
    Me.cboTavern.Value = ""
    Me.txtFirstname.Value = ""
    Me.txtSurname.Value = ""
    Me.txtCell.Value = ""
    Me.txtSecurityQ.Value = ""
    Me.txtSecurityA.Value = ""
    Me.Register.Value = ""
    Me.txtFirstname.SetFocus

End Sub


Private Sub UserForm_Initialize()
    
    Dim cTavern As Range
    Dim ws As Worksheet
    Set ws = Worksheets("lookuptavernlists")
    
    For Each cTavern In ws.Range("TavernList")
      With Me.cboTavern
        .AddItem cTavern.Value
        .List(.ListCount - 1, 1) = cTavern.Offset(0, 1).Value
      End With
    Next cTavern
    
End Sub

Private Sub cboTavern_Change()

    txtFirstname.Value = Range("B" & cboTavern.ListIndex + 2)
    txtSurname.Value = Range("C" & cboTavern.ListIndex + 2)
    txtCell.Value = Range("D" & cboTavern.ListIndex + 2)

End Sub
Private Sub cmdClose_Click()
    SAB_Registration_Form.Hide
End Sub




Vba: Excel Form That Updates Current Data On The Same Worksheet - Excel

View Content
Hi there,

I'm a novice with VBA and slowly improving my skills.

I've created an Excel VBA form that populates fields based on a combo Box (drop down). I can get this form to insert new records, but I can't get it to update an existing record.
Could someone please help me with the code? Code below:

Code:

Private Sub cmdSave_Click()

    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("lookuptavernlists")
    
    'find first empty row in database
    iRow = ws.Cells(Rows.Count, 1) _
      .End(xlUp).Offset(1, 0).Row
    
    'copy the data to the database / worksheet
    ws.Cells(iRow, 1).Value = Me.cboTavern.Value
    ws.Cells(iRow, 2).Value = Me.txtFirstname.Value
    ws.Cells(iRow, 3).Value = Me.txtSurname.Value
    ws.Cells(iRow, 4).Value = Me.txtCell.Value
    ws.Cells(iRow, 5).Value = Me.txtSecurityQ.Value
    ws.Cells(iRow, 6).Value = Me.txtSecurityA.Value
    ws.Cells(iRow, 7).Value = Me.Register.Value
    
    'clear the data
    Me.cboTavern.Value = ""
    Me.txtFirstname.Value = ""
    Me.txtSurname.Value = ""
    Me.txtCell.Value = ""
    Me.txtSecurityQ.Value = ""
    Me.txtSecurityA.Value = ""
    Me.Register.Value = ""
    Me.txtFirstname.SetFocus

End Sub


Private Sub UserForm_Initialize()
    
    Dim cTavern As Range
    Dim ws As Worksheet
    Set ws = Worksheets("lookuptavernlists")
    
    For Each cTavern In ws.Range("TavernList")
      With Me.cboTavern
        .AddItem cTavern.Value
        .List(.ListCount - 1, 1) = cTavern.Offset(0, 1).Value
      End With
    Next cTavern
    
End Sub

Private Sub cboTavern_Change()

    txtFirstname.Value = Range("B" & cboTavern.ListIndex + 2)
    txtSurname.Value = Range("C" & cboTavern.ListIndex + 2)
    txtCell.Value = Range("D" & cboTavern.ListIndex + 2)

End Sub
Private Sub cmdClose_Click()
    SAB_Registration_Form.Hide
End Sub




Figuring Out Current Page Number Of An Excel Worksheet In Vba - Excel

View Content
Hi,

I am looking to figure out some VBA code where I can determine page numbers "on the fly." For example, I am creating a large file, out of many smaller files. One of the files is 3 pages long. I need to put a footnote on the second page of this file, once Excel does it's automatic page break. I wanted to do it based on the page number of the second page of this particular document if possible.

I'd appreciate any help out there!

Excel Macro - How To Import External Worksheet To Current Workbook - Excel

View Content
Hello Experts,

I am struggling to figure out how to import a worksheet from an external workbook (closed one) into my current workbook using excel macro.

Can anyone plz suggest?

Cheers.

Excel Worksheet Print Out - Excel

View Content
hi,
yes there is.
see this site.
http://www.rondebruin.nl/files/Watermark.zip
regards
FSt1

"tikchye_oldLearner57" wrote:

> is there a way to have excel worksheet printed out with a watermark?
> --
> oldLearner57


Can I Print An Excel Worksheet W/o A, B, C On Top And 1,2,3 On Si. - Excel

View Content
I have made a page on Excel with columns of categories on the left side of
the sheet and labeled rows across the page to input info in each category by
date. How can I print this without the A, B, C, etc. across the top and the
1, 2, 3, etc. down the side?
Thanks!


Random Tutorials
Make a Thermometer Style Chart in Excel
(Intermediate)
FV() Find the Future Value of Cash Today
         -Savings/Retirement Plan Calculations

(Intermediate)
Remove #N/A Error Result from Empty VLOOKUP() Formulas
(Intermediate)
Introduction to Making Formulas in Excel
(Easy)
IF Statement Introduction & Using Nested IF's
(Easy)
Consolidate & Combine Data from Separate Worksheets or Workbooks(Excel Files)
(Intermediate)
Submit Inquiry Here
  • Prices From $10
Name:*
E-mail:*
Request:*
The macro(s) on this page will be sent with the request.
Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com