Forum Discussion

Akwangdiing's avatar
Akwangdiing
Occasional Reader
Nov 07, 2024

Excel VBA

good morning guys , my name is Logan.

I am new to this community and also new to the whole excel VBA thing.

I need your help in a project I am working on which is basically spreadsheet with 2 tabs (Database and Reports).

 

 what I want is automation of the process report capturing from the Database sheet  within the specified Dates when "generate report button" is pressed.

like for example: 

if the diagnosis is malaria , designation is GPOC ,age group is above 5 years and type of visit is a new visit  then update the circled cell by adding 1. 

this goes for the rest on the listed diagnosis.

 and thanks in advance.

  • You don't really need VBA for that - you can use formulas. For example in B2 (the indicated cell):

    =COUNTIFS(Database!$D$2:$D$1000, ">5years", Database!$E$2:$E$1000, "Male", Database!$F$2:$F$1000, "GPOC", Database!$I$2:$I$1000, "New Visit", Database!$J$2:$J$1000, $A2)

    Similar formulas in C2, D2 etc.

    Then fill down.

    In the Total row:

    =COUNTIFS(Database!$D$2:$D$1000, ">5years", Database!$E$2:$E$1000, "Male", Database!$F$2:$F$1000, "GPOC", Database!$I$2:$I$1000, "New Visit")

  • Akwangdiing's avatar
    Akwangdiing
    Occasional Reader

    Thank you HansVogelaar ,

    I have applied the same formula with some modifications but its does not capture any information from database .Its only showing 0 on the cells 

    • HansVogelaar's avatar
      HansVogelaar
      MVP

      Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?

Share

Resources