Results 1 to 20 of 22

Thread: Need to generate Open Order Report Filtered By Customer and Due date

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    744
    Location
    Frank Hi,

    Here's an autofilter based approach. What I will suggest is keeping one sheet as "Template" so you don't have to do formatting through VBA. If you don't want others to see the template then you may hide it (veryhidden). Make it visible during processing and then hide it again.

    Looking at the inputting, you can add Data Validation (Open / Closed) in Column A to avoid wrong inputs.

    At this point, the code doesn't create a new sheet for the report and there's no error handling. But it can be done once you decide your approach. I am attaching the revised workbook. The code is as below:
    [vba]Public Sub GetMeOpenReport()
    'Same Variable can be used as procedures don't overlap
    Dim lLR As Long, lLR2 As Long
    Application.ScreenUpdating = False
    'Filtering the data
    With Sheets("Data")
    .AutoFilterMode = False
    lLR = .Range("A" & Rows.Count).End(xlUp).Row
    .Range("A2:V" & lLR).AutoFilter Field:=1, Criteria1:="Open"
    .Range("A2:V" & lLR).AutoFilter Field:=3, Criteria1:=.Range("C1").Value
    Sheets("Template").Range("A2:J" & Rows.Count).ClearContents
    .Range("A3:O" & lLR).SpecialCells(xlCellTypeVisible).Copy _
    Destination:=Sheets("Template").Range("A2")
    .AutoFilterMode = False
    End With
    'Deleting unwanted data
    With Sheets("Template") 'hard coded as format will remain same
    lLR2 = .Range("A" & Rows.Count).End(xlUp).Row
    .Range("N2:N" & lLR2).Delete shift:=xlToLeft
    .Range("J2:J" & lLR2).Delete shift:=xlToLeft
    .Range("I2:I" & lLR2).Delete shift:=xlToLeft
    .Range("F2:F" & lLR2).Delete shift:=xlToLeft
    .Range("D2" & lLR2).Delete shift:=xlToLeft
    End With
    Application.ScreenUpdating = True
    End Sub
    [/vba]

    EDIT: I had tried my hand at pivot table through VBA http://www.vbaexpress.com/forum/showthread.php?t=38347
    Attached Files Attached Files
    Last edited by shrivallabha; 11-14-2011 at 12:42 AM.
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •