none
Pull Data with Conditions RRS feed

  • Question

  • Dear Experts,

    Greeting of the day..!!!!

    I need a macro for the below requirement.

    I have a master sheet from which i need to pull the Data.

    In the master data there is a Control sheet in which there is a list of center names & Categorization

    my requirement is like in a new workbook it should create two sheets (PPP and Non PPP), It should check the center name with categorization and sum the total count of particular month.

    In the above screen shot it shows the total sum of april 13 for all PPP Centers.

    In the same manner i need sum of all months of PPP and Non PPP centers.

    Please help me out with this macro

    Thanks in Advance...


    Monday, June 5, 2017 1:08 PM

All replies

  • Hi Anvesh Mudhamalle,

    you had posted the screen shot , so its looks like you had already try some code.

    but you did not posted the code or your workbook with dummy data.

    without your code how can we check that where is the issue and what needs to be change to solve the issue.

    try to post your code so that we can know that what you had tried and what you need to do further.

    you had mentioned that,"my requirement is like in a new workbook it should create two sheets (PPP and Non PPP), It should check the center name with categorization and sum the total count of particular month."

    so first you need to open your above workbook programmatically. so that you can fetch the data from it.

    then you need to create new workbook as per your requirement.

    below is an example to create new workbook.

    Sub AddNew()
    Set NewBook = Workbooks.Add
        With NewBook
            .Title = "All Sales"
            .Subject = "Sales"
            .SaveAs Filename:="Allsales.xls"
        End With
    End Sub
    

    Reference:

    Creating a New Workbook

    then you want to create worksheet

    ActiveWorkbook.Sheets.Add Before:=Worksheets(Worksheets.Count)

    Reference:

    Sheets.Add Method (Excel)

    then you can try to loop through the records in old workbook and try to copy them to new workbook as per category.

    last you can try to do sum on data in new worksheet.

    Total = Application.WorksheetFunction.Sum(columns("A:A"))

    then you can save the new workbook and close both workbooks.

    try to follow the steps and let us know if face any difficulty to implement these steps.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 6, 2017 2:34 AM
    Moderator
  • Hi Deepak,

    I haven't used any code the screen shot which i posted was done manually.

    Tuesday, June 6, 2017 5:02 AM
  • Hi Anvesh Mudhamalle,

    you had mentioned that,"I haven't used any code the screen shot which i posted was done manually."

    if you see my last reply then you will notice I had mentioned the logic, flow of the code.

    also I posted some code snippet as per specific step.

    you can try to understand the flow and try to start developing your own code.

    when you get any error or when you stuck somewhere then you can again ask a question here and we will try to help you to solve the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 6, 2017 6:46 AM
    Moderator