View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
[email protected] sauralf@gmail.com is offline
external usenet poster
 
Posts: 1
Default Converting from Decimal to Base-36 in Excel Formula

I also needed to do this -- and spent considerable time doing so to get the following. First, a few comments -- array formulas (row(indirect("1:10")) won't work for some reason, I think its because concatinate won't do it.. Sad, because it makes it harder.

Second,everywhere I see replies I see VBA or macros as an answer. While those work, the workbook is no longer safe and this isn't good. The code below can be pasted into excel and it will calculate. It assumes cell A1 has the number and D1 has the base you want to use.

I hope others find this helpful, I had a lot of fun figuring it out.

--Sauralf

Answer:

=CONCATENATE(
IF(FLOOR(A1/$D$1^12,1)=0,"",IF(MOD(FLOOR(A1/$D$1^12,1),$D$1)9,CHAR(MOD(FLOOR(A1/$D$1^12,1)-10,$D$1)+65),MOD(FLOOR(A1/$D$1^12,1),$D$1))),
IF(FLOOR(A1/$D$1^11,1)=0,"",IF(MOD(FLOOR(A1/$D$1^11,1),$D$1)9,CHAR(MOD(FLOOR(A1/$D$1^11,1)-10,$D$1)+65),MOD(FLOOR(A1/$D$1^11,1),$D$1))),
IF(FLOOR(A1/$D$1^10,1)=0,"",IF(MOD(FLOOR(A1/$D$1^10,1),$D$1)9,CHAR(MOD(FLOOR(A1/$D$1^10,1)-10,$D$1)+65),MOD(FLOOR(A1/$D$1^10,1),$D$1))),
IF(FLOOR(A1/$D$1^9,1)=0,"",IF(MOD(FLOOR(A1/$D$1^9,1),$D$1)9,CHAR(MOD(FLOOR(A1/$D$1^9,1)-10,$D$1)+65),MOD(FLOOR(A1/$D$1^9,1),$D$1))),
IF(FLOOR(A1/$D$1^8,1)=0,"",IF(MOD(FLOOR(A1/$D$1^8,1),$D$1)9,CHAR(MOD(FLOOR(A1/$D$1^8,1)-10,$D$1)+65),MOD(FLOOR(A1/$D$1^8,1),$D$1))),
IF(FLOOR(A1/$D$1^7,1)=0,"",IF(MOD(FLOOR(A1/$D$1^7,1),$D$1)9,CHAR(MOD(FLOOR(A1/$D$1^7,1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