Results 1 to 3 of 3

Thread: Macro or VBA to sort values

  1. #1
    Junior Member
    Join Date
    Apr 2022
    Posts
    1
    Rep Power
    0

    Macro or VBA to sort values

    My spreadsheet has 100 values on column B from B6 to B106the values have the below form

    AB, BC, CD, DE

    I need to copy the column D the AB values, in column E the BC values, in column F the CD values, in column G the DE values


    I tried to create a macro however, i didn't succeed. can anyone help?


    Thanks!

  2. #2
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Hello ntldr123
    Welcome to ExcelFox

    ( Usually when asking for help, asking for Macro or VBA means the same thing )

    It’s not too clear exactly what you want. For example you have not said which rows the copied values should go in.
    If you want the number of values of , for example , AB , that appear in column B to go in column D, then another possibility would be to count how many times AB appears in column B and then put that many values of AB in column D. There would then be no need to copy, and just putting in a number of values usually would be easier and quicker.

    Perhaps you could show us exactly what you want.
    Perhaps upload a file with maybe two sheets on it, or two files with a sheet on each.
    One sheet would be what you start with, and the other you should fill in manually to do what you want the coding to do. You don’t necessary need to include all 100 values – just enough to show clearly what you want.

    If you show us your attempt so far, that will also help us to determine what level to pitch our help at.

    ( How to upload files is not obvious at excelfox. These notes might help
    https://excelfox.com/forum/showthrea...ll=1#post11279
    https://excelfox.com/forum/showthrea...ll=1#post15589
    )

    Alternatively get us a sample file or files some other way, such as through a file sharing place.


    Alan

  3. #3
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    Code:
    Sub M_snb()
      sn = Split("_" & Join([transpose(B6:B106)], "|_"), "|")
      ReDim sp(UBound(sn), 26)
      
      For j = 65 To 90
         st = Filter(sn, "_" & Chr(j))
         For jj = 0 To UBound(st)
            sp(jj, j - 65) = Mid(st(jj), 2)
         Next
      Next
      
      Cells(1, 3).Resize(UBound(sp) + 1, UBound(sp, 2) + 1) = sp
    End Sub
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://eileenslounge.com/viewtopic.php?p=316441#p316441
    https://eileenslounge.com/viewtopic.php?p=324736#p324736
    https://eileenslounge.com/viewtopic.php?p=324990#p324990
    https://eileenslounge.com/viewtopic.php?f=27&t=41937&p=325485#p325485
    https://eileenslounge.com/viewtopic.php?p=325609#p325609
    https://eileenslounge.com/viewtopic.php?p=325610#p325610
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGADdPM65i9PG
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGADdPQHFk_zm
    http://www.eileenslounge.com/viewtopic.php?p=324457#p324457
    http://www.eileenslounge.com/viewtopic.php?p=324064#p324064
    http://www.eileenslounge.com/viewtopic.php?p=323960#p323960
    https://www.youtube.com/watch?v=7VwD9KuyMk4&lc=UgyZCnNfnZRfgwzDlQF4AaABAg
    https://www.youtube.com/watch?v=7VwD9KuyMk4&lc=UgyZCnNfnZRfgwzDlQF4AaABAg. ADd4m2zp_xDADd6Nnotj1C
    s://www.youtube.com/watch?v=7VwD9KuyMk4&lc=UgySdtXqcaA27wQLd1t4AaABAg
    http://www.eileenslounge.com/viewtopic.php?p=323959#p323959
    http://www.eileenslounge.com/viewtopic.php?f=30&t=41784
    http://www.eileenslounge.com/viewtopic.php?p=323966#p323966
    http://www.eileenslounge.com/viewtopic.php?p=323959#p323959
    http://www.eileenslounge.com/viewtopic.php?p=323960#p323960
    http://www.eileenslounge.com/viewtopic.php?p=323894#p323894
    http://www.eileenslounge.com/viewtopic.php?p=323843#p323843
    https://www.youtube.com/watch?v=fEHKPhJxgBA&lc=Ugxx8_MjhC9FDaQgcHN4AaABAg
    https://www.youtube.com/watch?v=jpjYm4UvyWk&lc=Ugx_Qd4rfAN_ZYcJbo94AaABAg. ACGbG9c76OWACGbjKa7H8k
    https://www.youtube.com/watch?v=jpjYm4UvyWk&lc=Ugx_Qd4rfAN_ZYcJbo94AaABAg
    https://www.youtube.com/watch?v=GyPHaydeng0&lc=UgzE4a4f_e_y9Rk5OR94AaABAg
    https://www.youtube.com/watch?v=I5FkNG94BcQ&lc=UgxXnkEHqulXSR5tXwh4AaABAg
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa6BSa173Z
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa6-64Xpgl
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa5ms39yjd
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa5ZXJwRCM
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa4Pr15NUt
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa4I83JelY
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGADdMo2n-hyF
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 03-25-2025 at 02:28 PM.

Similar Threads

  1. PQ - Sort ascending values by minimum value from each group
    By sandy666 in forum ETL PQ Tips and Tricks
    Replies: 0
    Last Post: 05-11-2020, 04:21 AM
  2. Replies: 5
    Last Post: 01-08-2014, 04:54 PM
  3. Replies: 10
    Last Post: 08-29-2013, 08:20 PM
  4. Replies: 6
    Last Post: 05-10-2013, 01:13 AM
  5. Excel Macro to Sort Data if a value changes in defined range
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 4
    Last Post: 09-05-2012, 10:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •