I am looking to sort a column alphabetically (E) but I need to change the values in my columns in order for the alphabetical order to be correct ex: I have R1, R2, R3...R100, CN1, CN10, etc... Alphabetically R100 goes before R2. So I have this very large formula with embedded Ifs, Concatenates, etc.. to add buffer zeros (R001, R002, R100, CN001,...)
Right now, my macro is adding a column with my formula (R1C1), sorting the table according to this new column, then deleting the column afterwards.
I am fairely new with VBA and wondering how I could create a range from this formula, and sort directly my correct column from this new range.
(how would I even create this range from my other range, wihtout storing it in another column?)
For exemple:
ActiveWorkbook.Worksheets("sheet1").Select
Columns("E:M").Sort key1:=CREATED_RANGE, order1:=xlAscending, Header:=slYes
My formula for the 000 padding is
=IF(ISBLANK(E2)=FALSE,IF(ISERROR(VALUE(RIGHT(E2,3)))=FALSE,E2,IF(AND(ISERROR(VALUE(MID(E2,2,1)))=TRUE,ISERROR(VALUE(RIGHT(E2,2)))=FALSE),CONCATENATE(LEFT(E2,2),0,RIGHT(E2,2)),IF((AND(ISERROR(VALUE(MID(E2,2,1)))=FALSE,ISERROR(VALUE(RIGHT(E2,2)))=FALSE)), CONCATENATE(LEFT(E2,1),0,RIGHT(E2,2)),IF(ISERROR(VALUE(MID(E2,2,1)))=TRUE,CONCATENATE(LEFT(E2,2),"00",RIGHT(E2,1)),CONCATENATE(LEFT(E2,1),"00",RIGHT(E2,1))))))," ")