PDA

View Full Version : VBA Code to pull selected data from a huge database



baron11
07-29-2008, 03:55 PM
I have a 4 column database with the following entries

Period Index 1 Index 2 Correlation

30D A b 0.1
' c d 0.5 ' ' ' 0.8

60D X Y 0.4


This database have more than 60000 entries and I want to selectively pull entries where the 60D-30D correlation values in table 4 are greater than 0.3

For example 0.8-0.4 > 0.3 so return those entries

malik641
07-29-2008, 07:49 PM
You could just use AutoFilter for that.

Select your data, then click Data->Filter->AutoFilter

You'll see the drop down arrows.

-Click the arrow in Period and click "Custom..."
-Select "greater than or equal to" and for the value type '30D' (without apostraphes)
-Make sure "AND" is clicked
-Choose a second condition "less than or equal to" and for the value type '60D' (without apostraphes)
-Click OK

This is half the battle. Now...

-Click the arrow in Correlation and click "Custom..."
-Select "greater than or equal to" and for the value type '0.4' (without apostraphes)
-Make sure "AND" is clicked
-Choose a second condition "less than or equal to" and for the value type '0.8' (without apostraphes)
-Click OK

And there you have it. That should do what you are looking for (I tried inputting really bad data that didn't match the format of the Period column and excel still picked it up pretty well!).

Hope this helps!

baron11
07-30-2008, 04:19 PM
Thanks a lot; I will try this soon.