yenilik025
Altın Üye
- Katılım
- 28 Eylül 2005
- Mesajlar
- 233
- Excel Vers. ve Dili
- 2007
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Sub PdfKaydet_Filtre()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sayfa1")
Dim LastRow As Long
LastRow = ws.Cells(ws.Rows.Count, "G").End(xlUp).Row
Dim FilterRange As Range
Set FilterRange = ws.Range("G2:G" & LastRow)
Dim FilterValues() As Variant
FilterValues = GetFilterValues(FilterRange)
Dim i As Long
For i = LBound(FilterValues) To UBound(FilterValues)
ws.Range("G2:G" & LastRow).AutoFilter Field:=1, Criteria1:=FilterValues(i)
ws.Range("A1", ws.Cells(ws.Rows.Count, "G").End(xlUp)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
ActiveSheet.PageSetup.FitToPagesWide = 1
ActiveSheet.PageSetup.FitToPagesTall = 1
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & FilterValues(i) & "_Grup.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Next i
ws.AutoFilterMode = False
End Sub
Function GetFilterValues(FilterRange As Range) As Variant
Dim FilterValues() As Variant
Dim FilterCell As Range
Dim i As Long
i = 0
For Each FilterCell In FilterRange
If FilterCell.Value <> "" Then
i = i + 1
ReDim Preserve FilterValues(1 To i)
FilterValues(i) = FilterCell.Value
End If
Next FilterCell
GetFilterValues = FilterValues
End Function
2. numaralı makroyu güncelledim.
Sub PdfKaydet_Filtre2007 ()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sayfa1")
Dim LastRow As Long
LastRow = ws.Cells(ws.Rows.Count, "G").End(xlUp).Row
Dim FilterRange As Range
Set FilterRange = ws.Range("G2:G" & LastRow)
Dim FilterValues() As Variant
FilterValues = GetFilterValues(FilterRange)
Dim i As Long
For i = LBound(FilterValues) To UBound(FilterValues)
ws.Range("G2:G" & LastRow).AutoFilter Field:=1, Criteria1:=FilterValues(i)
ws.Range("A1", ws.Cells(ws.Rows.Count, "G").End(xlUp)).ExportAsFixedFormat _
Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "" & FilterValues(i) & "_Grup.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
Next i
ws.AutoFilterMode = False
End Sub
Function GetFilterValues(FilterRange As Range) As Variant
Dim FilterValues() As Variant
Dim FilterCell As Range
Dim i As Long
i = 0
For Each FilterCell In FilterRange
If FilterCell.Value <> "" Then
i = i + 1
ReDim Preserve FilterValues(1 To i)
FilterValues(i) = FilterCell.Value
End If
Next FilterCell
GetFilterValues = FilterValues
End Function
Sub pdflereBol()
Dim lr&, rng As Range, lst, grp
With ActiveSheet
lr = .Cells(Rows.Count, "G").End(3).Row
If lr > 2 Then
Set rng = .Range("A2:G" & lr)
.PageSetup.PrintArea = "A1:G" & lr
.PageSetup.Orientation = xlPortrait
.Range("M:M").Clear
rng.Columns(7).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("M1"), Unique:=True
lr = .Cells(Rows.Count, "M").End(3).Row
For Each grp In .Range("M2:M" & lr).Value
rng.AutoFilter Field:=7, Criteria1:=grp
.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & grp & "_Grup.pdf", Quality:=xlQualityStandard
Next
.AutoFilterMode = False
.Range("M:M").Clear
End If
End With
End Sub