moved selected row to top/first row with filtering data

  • hi everyone,

    Apologize if this question repeated since i couldn't find in sub-forums,

    i am very new in VBA and learning more, i have one situation here..
    currently i have excel data and its converted to PDF with macros, one data column (column B) are contain False\True words but than i converted it into YES/NO because i wanted to be display in my pdf. But, before its convert into pdf i would like to filter all YES data to be at first row to display in pdf.
    fyi I'm having 6 column to be displayed in pdf (A-F).

    anyone can suggest?

  • Hello,
    Filter the Yes/No column decending ZtoA and they will be first in the column


    thank you for your reply,
    can you advice the vba coding for descending ZtoA?
    several code i tried but its gave me multiple error response, i tried also try with sorting but still not work.
    i would like to sort Z to A from Column A data with unknown end, i mean the entire C column.

    sorry for repeating the question.

  • Recording a Macro shows this:

    You just need to adjust the sheet names and ranges to suit your needs!


    There are 10 types of people in the world. Those that understand Binary and those that dont. :P

    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)


  • Recording a Macro shows this:

    You just need to adjust the sheet names and ranges to suit your needs!


    hi Ger,

    Thank you for your advice,
    i'm trying to put the code but its gave me runtime 438 error on this code :

    i would like to set descending data based on column C. I tried to change the =Range ("C1") and still giving same response.
    i think i made another mistake to judge the code x_X

  • Hello Tbhendralesmana,

    You should only need the following short code to do the sorting of Columns A:F based on Column C descending:-

    Sub SortIt()
    Sheet1.Range("A2", Sheet1.Range("F" & Sheet1.Rows.Count).End(xlUp)).Sort Sheet1.[C2], 2
    End Sub

    It assumes that you have headings in row1 and the data starting in row2.

    I have used the sheet code (Sheet1) in the code and not the sheet name. To find your actual sheet code, open the VB Editor and over to the left, you'll see all your sheet names listed in parentheses(). The sheet codes are immediately to the left of the sheet names. Change it in the code to suit if need be.

    I hope that this helps.


  • Hi Vcoolio.

    The code working very well!
    thank you so much for your help and advice :D


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!