Print Area - Microsoft Community


how print non adjacent areas on single page?

hide ranges don't want print.

or use macro print selected or preset areas.

sub print_noncontiguous()
    dim destrange range
    dim smallrng range
    dim newsh worksheet
    dim ash worksheet
    dim lr long

    application.screenupdating = false

    set ash = activesheet
    set newsh = worksheets.add
    ash.select

    lr = 1

    each smallrng in selection.areas
    
    'you can use range more preset areas this
    'for each smallrng in ash.range("a1:c1,d10:g20,a30:e41").areas

        smallrng.copy
        set destrange = newsh.cells(lr, 1)
        destrange.pastespecial xlpastevalues
        destrange.pastespecial xlpasteformats
        lr = lr + smallrng.rows.count
    next smallrng

    newsh.columns.autofit
    newsh.printout   'printpreview

    application.displayalerts = false
        newsh.delete
    application.displayalerts = true

    application.screenupdating = true

end sub

gord



Office / Excel / Microsoft Office Programming / Office 365 Home



Comments

Popular posts from this blog

Getting ErrorCode: 120018 when trying to access Microsoft account - Microsoft Community

The message was sent to a distribution list ‎(DL)‎ - Microsoft Community

Activation Error 0x8004FE93 - Microsoft Community