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,446
    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
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  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

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
  •