masthead for advanced excel

Sample Excel Macro Codes

The macro below show how we can select multiple files to run
Sub OpenMultipleFiles()
Dim fn As Variant, f As Integer
    fn = Application.GetOpenFilename("Excel-files,*.xls", _
        1, "Select One Or More Files To Open", , True)
    If TypeName(fn) = "Boolean" Then Exit Sub
    For f = 1 To UBound(fn)
        'run another macro to process the selected files
    Next f
End Sub

For Page Setup

If you want to setup the page to fit within one page for printing, you have to use the code below. It is important to add the .zoom=false line to switch off the zoom. Without it, the macro will not work.

With ActiveSheet.PageSetup
     .Zoom = False 
     .FitToPagesWide = 1
     .FitToPagesTall = 1
End With


New! Comments

Have your say about what you just read! Leave me a comment in the box below.