• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Vba Code To Automatically Print Data In Sheet For Each Date In Table

861171314

New Member
Hello Dears
I Have A Problem
Is There Any Way To Write Vba Code To Print Table Data In Separate Page for Each Different Date ?
For Example
Date Name Code cost
01/02/2018 Mohammad 03 7000
06/02/2018 Mohammad 03 6000
01/04/2018 Hasan 01 8000
01/04/2018 Mohammad 03 2000
21/01/2018 Davood 04 3000
11/03/2018 Davood 04 5000
01/02/2018 Mohammad 03 3000
10/04/2018 Hasan 01 8000
01/04/2018 Davood 04 1000

I Want A Vba Code To Print Data Automatically By Date
Page One
01/02/2018 Mohammad 03 7000
01/02/2018 Mohammad 03 3000

Page Two
06/02/2018 Mohammad 03 6000

Page Three
01/04/2018 Hasan 01 8000
01/04/2018 Mohammad 03 2000
01/04/2018 Davood 04 1000

And ....

Thank you in advance
 
861171314
Many things are possible ...
but without even good sample file
You'll have a second problem challenge ... how to use it?
Create a sample file with needed output
... and upload it here.
 
an alternative solution here that uses a Dictionary to control things
 

Attachments

  • Filter and Print.xlsm
    20.8 KB · Views: 7
Hi !

An easy beginner way just using advanced filters :​
Code:
Sub Demo1()
    Application.ScreenUpdating = False
With [A1].CurrentRegion
        .Parent.PageSetup.PrintArea = .Address
        .Columns(1).AdvancedFilter xlFilterCopy, [I1:I2], [H1], True
    For R& = 2 To [H1].CurrentRegion.Rows.Count
        [H2].Value = Cells(R, 8).Value
        .AdvancedFilter xlFilterInPlace, [H1:H2]
        .Parent.PrintOut
    Next
        If .Parent.FilterMode Then .Parent.ShowAllData
End With
    [H1].CurrentRegion.Clear
    Application.ScreenUpdating = True
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
As I met an issue my very first try was to filter & copy data to another sheet
but once it's solved an easy filter does well the job in the loop
so according to original sample workbook :​
Code:
Sub Demo2()
    Application.ScreenUpdating = False
With [A1].CurrentRegion
        .Parent.PageSetup.PrintArea = .Address
        .Columns(1).AdvancedFilter xlFilterCopy, , [H1], True
    For R& = 2 To [H1].CurrentRegion.Rows.Count
        .Columns(1).AutoFilter 1, Cells(R, 8).Value
        .Parent.PrintOut
    Next
        If .Parent.FilterMode Then .AutoFilter
End With
    [H1].CurrentRegion.Clear
    Application.ScreenUpdating = True
End Sub
You may Like it !
 
Back
Top