Excel - copy excel filtered cells

I have a set of data (several rows and several columns) in one excel spreadsheet. It's possible to apply filter on some columns and as a result some rows become hidden.
I would like to copy the visible cells only but when I select some rows using "Range" matlab gets every rows existing inside the defined range, the visible ones and the hidden one.
Is there a way to select the visible cells only ? Or do you have any idea to go around it ?
Thanks a lot!

3 Comments

What kind of filtering are you using? Can you not just filter the results in the imported Matlab information?
The reason the import doesn't work this way is because Excel doesn't technically get rid of the information between, it just hides the filtered rows. You could edit your range to include the specific rows, but most likely that will be more effort than it's worth. You can also try copy and pasting the visible excel information into a matrix in matlab, but any mixed information will make this difficult.
The filtering can be various and is not predictable. One example would be to filter all the empty cells of one column.
At the moment I use an excel macro to copy the filtered data only and paste it in a new spreadsheet read by matlab.
When I copy/paste manually the filtered data, I only get the visible cells (not the ones hidden between the visible ones). My guess was that it should be possible to code that same process. Maybe there is a flag making the distinction between visible and hidden cells once a filter is applied ?
It might be possible to identify the visibility flag using the ActX server, but doing so would force you to probably rewrite your entire interction with Excel. I suggest sticking with the macro you have written now, unless there are more specific issues of why you don't like that method.

Sign in to comment.

Answers (0)

Asked:

on 9 Jan 2020

Commented:

on 9 Jan 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!