vbamania.pl
login:
hasło:
 
  *Rejestracja *Zapomniane hasło
 Dziś jest piątek, 19 kwietnia 2024 roku.
Ustaw jako stronę startową Ulubione Napisz
PowrótPowrót do serwisu  RegulaminRegulamin rssRSS

  tytuł wątku:
Wątki dyskusji

Drukowanie kilku skoroszytow za pomoca VBA


otwartyotwarty rozpoczął: nantye postów: 2



napisał: admin
postów: 613


umieszczony:
16 stycznia 2023
20:32

  
Witam,

może tak:

Sub Printing()

Dim Target As String

Target = Sheets("Centrum").Range("G7").Value

If Target = "" Then Exit Sub

Dim vSheetArray As Variant
Dim i As Long
 
If Target = "All" Then
    vSheetArray = Array("GREEN", "BLUE", "YELLOW", "GREY", "BLACK")
Else
    vSheetArray = Array(Target)
End If

For i = LBound(vSheetArray) To UBound(vSheetArray)
    Sheets(vSheetArray(i)).PageSetup.PrintGridlines = True
    Sheets(vSheetArray(i)).Visible = True
Next i

Sheets(vSheetArray).PrintOut copies:=1, Collate:=True

For i = LBound(vSheetArray) To UBound(vSheetArray)
     Sheets(vSheetArray(i)).Visible = False
Next i

End Sub



pozdrawiam
Admin

Cytat:
Czesc, witam


Potrzebuje pomocy.

W zakladce "Centrum" w punkcie G7 mam do wyboru liste rozwijana, ktora zawiera nazwy zakladek:
GREEN
BLUE
YELLOW
GREY
BLACK
All

Drukowanie samo w sobie, gdy wybieram dana zakladke i klikam makro - dziala. Strona sie drukuje.
Potrzebuje dograc jeszcze opcje, w ktorej gdy wybiore "All" to wydrukuja sie wszystkie zakladki.
Wazne - w pliku sa jeszcze inne zakladki z danymi, ktorych nie chce drukowac (wiec print whole workbook nie wchodzi w gre)
Prosze o pomoc, bo wyskakuje mi blad, ze if jest zablokowany.


Dziekuje z gory!


KOD:

Sub Printing()


Target = Sheets("Centrum").Range("G7").Value



If Target = "All" Then With Worksheets("GREEN") & Worksheets("BLUE") & Worksheets("YELLOW") & Worksheets("GREY") & Worksheets("BLACK")
.Visible = True
.PageSetup.PrintGridlines = True
.PrintOut Copies:=1, Collate:=True
.Visible = False
End If

Target = Sheets("Centrum").Range("G7").Value
If Not Target = "All" Then With Sheets(Target)
.Visible = True
.PageSetup.PrintGridlines = True
.PrintOut Copies:=1, Collate:=True
.Visible = False

End If
End With
End Sub


napisał: nantye
postów: 1


umieszczony:
16 stycznia 2023
16:21

  
Czesc, witam


Potrzebuje pomocy.

W zakladce "Centrum" w punkcie G7 mam do wyboru liste rozwijana, ktora zawiera nazwy zakladek:
GREEN
BLUE
YELLOW
GREY
BLACK
All

Drukowanie samo w sobie, gdy wybieram dana zakladke i klikam makro - dziala. Strona sie drukuje.
Potrzebuje dograc jeszcze opcje, w ktorej gdy wybiore "All" to wydrukuja sie wszystkie zakladki.
Wazne - w pliku sa jeszcze inne zakladki z danymi, ktorych nie chce drukowac (wiec print whole workbook nie wchodzi w gre)
Prosze o pomoc, bo wyskakuje mi blad, ze if jest zablokowany.


Dziekuje z gory!


KOD:

Sub Printing()


Target = Sheets("Centrum").Range("G7").Value



If Target = "All" Then With Worksheets("GREEN") & Worksheets("BLUE") & Worksheets("YELLOW") & Worksheets("GREY") & Worksheets("BLACK")
.Visible = True
.PageSetup.PrintGridlines = True
.PrintOut Copies:=1, Collate:=True
.Visible = False
End If

Target = Sheets("Centrum").Range("G7").Value
If Not Target = "All" Then With Sheets(Target)
.Visible = True
.PageSetup.PrintGridlines = True
.PrintOut Copies:=1, Collate:=True
.Visible = False

End If
End With
End Sub



<-wstecz  1  dalej->
wszystkich stron: 1


Sortuj posty: z