RSS Feed

Syndicate content

Ho realizzato un foglio excel, denominato griglia, con un elenco, dove ogni casella è collegata per nome, data e committente, ad altrettanti successivi fogli excel con disegno. Come posso stampare solo alcuni fogli con disegno selezionandoli dalla griglia?

Submitted by Anonimo on Wed, 17/12/2008 - 12:32

La procedura è la seguente:

 

immaginiamo di avere un foglio il cui nome è Griglia e tre fogli su cui ci sono i dati da stampare "Foglio1", "Foglio2" e "Foglio3":

 

 

A fianco di ogni foglio inseriamo un "Si" o un "No" per indicare se il foglio deve essere stampato o meno. Ovviamente i fogli devono essere già formattati per la stampa. Nel file Excel allegato troverete una formula per garantire che il nome dei foglio qui rappresentato sia esatto. Se compare un nome in questo elenco che non corrisponde a un nome del foglio, la  macro si bloccherà con un errore.

La seguente Macro cerca i nomi dei fogli che hanno associato un "Si", li seleziona tutti contempraneamente e li manda in stampa:

Sub Stampa_selettiva()
'
' Macro registrata il 18/12/2008 da Aterzaghi
'
  
   Dim i As Integer
   Dim j As Integer
   Dim Fogli As Variant
   Dim GRIGLIA As Worksheet
  
   Set GRIGLIA = Worksheets("Griglia")
  
   i = 3
   j = 0
   While GRIGLIA.Cells(i, 3).Value <> ""
  
       If GRIGLIA.Cells(i, 3).Value = "Si" Then
            If j = 0 Then
                Fogli = Array(GRIGLIA.Cells(i, 2).Value)
            Else
                ReDim Preserve Fogli(j)
                Fogli(j) = GRIGLIA.Cells(i, 2).Value
            End If
           
             j = j + 1
       
       End If
       i = i + 1
   Wend

    Sheets(Fogli).Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Sheets("GRIGLIA").Select
End Sub

 

Ovviamente la macro è flessibile: è possibile aggiungere quanti fogli si desidera e cambiare i nomi ai fogli

AttachmentSize
stampa_selettiva.zip9.02 KB

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <style> <center> <p>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Custom Search