Welcome to my website!

All my tutorials are here to teach you how to use a few lines of codes to automate repetitive tasks which will save us tremendous amount of time.

#4: How to loop through all rows and copy filtered data to a new sheet?

Clinical Research Data 101

Tools/Languages: Excel VBA Macro

This tutorial shows you how to automatically loop through all rows, find the IDs with missing data access group (DAG) names, copy/paste the filtered data to a new sheet and save the new sheet in one click.


It's super helpful if you have more than 100 participants from more than 1 site.
Or when you need to generate a list of participants with missing site names or numbers.

First of all, here's the link to learn how to turn on the "Developer Mode" in your Excel.

What happened?

In clinical research, we often need to track participants' status. Usually we would have a spreadsheet of participants IDs with previously assigned site numbers. For example, UCLA is site 01 and UC Santa Cruz is site 02, etc. In the electronic data capture system (REDCap), the site numbers should be used as the best indicator for sites, since it's easy to mispell the site names and there're multiple ways to write the same site names. This tutorial is to simulate the situation when you export the report data to Excel spreadsheet as raw data.

In the online EDC, hundreds of records are entered by site coordinators from different institutions, you'd like to quickly generate a list of participants who have not been assigned to a site (a typical error on the site), knowing that the missing data is coded as either 99 or 0.
Your goal is to first find all IDs with missing DAG and then copy the whole row to a new sheet. In this case, you can create a loop to accomplish that.

What should I do now?

Please leave me a message if it doesn't work for you.