Combined CSV Data Connection and Filter

gijimbo

Board Regular
Joined
Feb 3, 2010
Messages
130
I have a worksheet that gets the majority of its data from a csv file that gets updated daily. I have it setup so that the workbook refreshes/re-imports the csv data when the workbook is opened.

I currently would like to be able to control the viewing of the data using excel's filter capability. This is fine except when the csv file grows larger, the range of data that is covered by the filter is only as large as when it was first created. The only way I can make it encompass all of the data is to remove the filter and re-add the filter.

I tried doing this through a macro that runs when the workbook is opened except it does not work because it runs before the csv file gets checked and the new data is added to the worksheet.

Does anyone know a better way to do this?
Maybe some method of making the filter range dynamic?
Or making the filter range dependent on the length of one of the columns somehow?

My primary goal is to have the csv update and the filter cover all the data via some automated method at startup. I can not have the users turning the filter on and off every time they open the workbook.

Any responses are appreciated.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Solution: (in case anyone has the same issue in the future)

The fix was pretty simple. I just had to disable the data auto-update when the workbook is opened and add the following to the beginning of my macro (which is called when the workbook is opened). This makes it so the data still updates when the workbook opens but it makes sure it's done before the macro is run.

Code:
'Refresh data file
ActiveWorkbook.RefreshAll
After the "refresh", I just used the following to re-dimension the filter range.

Code:
Range("A2").AutoFilter 'Remove current filter
Range("A2").AutoFilter 'Add new filter
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,240
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top