Very much a macro noob here, spent all day on this problem and can't seem to find a solution to it
I've got the following spreadsheet
graph picture.PNG
Now what I want to do is create a macro which removes all the white space from an individual column, showing only the numbers other than zero and their corresponding dates
The final table after doing this for one column looks like this
Filter table example.PNG
I did this by simply unticking 'blank' when I opened the filter menu and it somehow worked
Now however, I want to make it so that whenever I click on one of the cells on the 'data' row and press a macro button, it will do the exact same to that column of data, I've tried making this a macro by performing this process with 'use relative references' on, however excel always writes the VBA code for it as -
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Range("$F$9:$F$1004").AutoFilter Field:=1, Criteria1:="="
ActiveSheet.Range("$F$9:$F$1004").AutoFilter Field:=1, Criteria1:="<>"
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveCell.Offset(7, 5).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Select
End Sub
So the big problem that I can see right now is that the range for the active sheet thing is in absolute terms, while everything else is in relative terms, I'm not entirely sure how to change this or what I should be doing differently
The closest thing I've thought of is the particularly hamfisted approach of changing the filter code to -
ActiveSheet.Range(ActiveCell.Offset(1, 0).Range("A1:A1000")).AutoFilter Field:=1, Criteria1:="="
ActiveSheet.Range(ActiveCell.Offset(1, 0).Range("A1:A1000")).AutoFilter Field:=1, Criteria1:="<>"
However this isn't working and debugger says that these lines are the reason why
Anyone have any idea what I could do here?
Apologies if this is something you learn to fix in lesson one of vba academy, I'm rather clueless as to what I'm doing, never coded before or anything even remotely similar.
Thank you very much
Bookmarks