PDA

View Full Version : Macro or VBA to sort values



ntldr123
04-27-2022, 06:31 PM
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!

DocAElstein
04-27-2022, 08:19 PM
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/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=11279&viewfull=1#post11279
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=15589&viewfull=1#post15589 )

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


Alan

snb
04-29-2022, 11:46 AM
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