1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

  2. 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


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

Need to populate monthly sheet based on month #[code]&[/code]

Discussion in 'VBA Macros' started by abusarah, Aug 9, 2018.

  1. abusarah

    abusarah New Member

    hi all,
    i want to populate my "monthly" stats sheet, when i input the month and year in the reference cell and press the update button in "monthly" sheet. The "data" sheet is updated from the daily sheet when the user clicks the save button. This part is already done. just need to figure out how to match the specific month datas from dates.

    Attached Files:

  2. Belleke

    Belleke Active Member

    Something like this?
    See attached.
    Never use merged cells when you are using VBA
    I also changed your SAVE code.
    First, it was not correct but above all avoid using Select and/or Activate, it slows down your code big time and it is rarely needed.
    I added a column in your data sheet that compares the months and years with the month and year in your monthly sheet to populate your monthly sheet
    For this question you also could use a pivot table.

    Attached Files:

    abusarah likes this.
  3. abusarah

    abusarah New Member

    thanks for your help.
    but when i delete the data and update data sheet with new data and then click update with a new month on monthly sheet, it does not work? what did i do?
  4. Belleke

    Belleke Active Member

    If I understand the problem.
    Second version should solve the problem.

    Attached Files:

    abusarah likes this.
  5. abusarah

    abusarah New Member

    this works wonderfully. thanks
  6. Marc L

    Marc L Excel Ninja

    Hi !
    As always the easy way is an Excel feature (respecting the main rule TEBV)
    needing a single codeline to copy data : an advanced filter !
    Like any Excel beginner can yet achieve manually …
    (As it removes the filters of the source table, tell me if you need to keep them.)
    Code (vb):
    Private Sub Button1_Click()
        With Sheet4
            V = .[A2].Value:  If Not IsDate(V) Then Beep: Exit Sub
           .[C1:D2].Value2 = Evaluate("{""Date"",""Date"";"">=" & V & """,""<" & DateSerial(Year(V), Month(V) + 1, 1) & """}")
            Sheet3.ListObjects(1).Range.AdvancedFilter xlFilterCopy, .[C1:D2], .[A4:M4]
        End With
    End Sub
    Do you like it ? So thanks to click on bottom right Like !
    Thomas Kuriakose likes this.

Share This Page