After filtering, range AF16:AF1150 of my worksheet consists of visible values, zero values and blank cells. Using VBA I want to copy the visible values within this range to col AQ, commencing at AQ16, so that I have just the visible non-zero values in a continuous sequence - no zero values and no blank cells. Can somebody please assist with VBA to achieve this.
If it assists, the area of the worksheet to the right of col AQ is blank and can be used to hold temporary data if required.
Thanks.
VBA to Copy Visible Cells and Delete Blank Cells and Zero Values
- OldFella
- Thread is marked as Resolved.
-
-
-
Re: VBA to Copy Visible Cells and Delete Blank Cells and Zero Values
So essentially you have filtered the data down to display a subset.
You want code to extract the values that are viewable whilst ignoring rows that have been hidden (filtered) and rows that contain nothing ("", vbnullstring).
Is that correct?
If so should it just start on row 16 or is that because that's the first visible row? (Not a good idea to hardcode something like that if it could change following different formatting or resorting of the data)
Also, what should prompt it to end the extract of the data before outputting the results in AQ?
-
Re: VBA to Copy Visible Cells and Delete Blank Cells and Zero Values
QuoteSo essentially you have filtered the data down to display a subset.
You want code to extract the values that are viewable whilst ignoring rows that have been hidden (filtered) and rows that contain nothing ("", vbnullstring).
Is that correct?
You're correct on both points, but in addition I also want to remove zero (0) values. The following screen shot shows a small section of the raw data, and the output that I'm looking for.
[ATTACH=CONFIG]73893[/ATTACH]Quote
If so should it just start on row 16 or is that because that's the first visible row? (Not a good idea to hardcode something like that if it could change following different formatting or resorting of the data)The data starts at row 16; rows 1 - 15 are used as a sort of control panel and contains headers, an assortment of subset results, and control buttons. I should note that the data cannot be sorted to get rid of the zeros and blank cells. The data is there in date order, running down the column, and the sequence needs to be maintained after the blanks and zeros are extracted.
QuoteAlso, what should prompt it to end the extract of the data before outputting the results in AQ?
I'll assign the VBA coding to a control button so that I can run it as/when required.
I've realized that copying the col AF data to AQ16 may not be such a smart idea as the rows that are hidden as a result of the filter may introduce new problems. Instead it would seem better to copy col AF to the area below the filtered data. So, instead of starting the copied data at AQ16 it should now start at AQ1500. As before, the area to the right of col AQ is blank and can be used to hold temporary data if required.
I hope that clarifies it a bit better.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!