BASE64DECODE

=BASE64DECODE(stringToDecode)

stringToDecode
required. The string that will be decoded from Base64

Decodes Base64 encoded string

felixstraube

Well-known Member
Joined
Nov 27, 2023
Messages
897
Office Version
  1. 365
Platform
  1. Windows
  2. Web
BASE64DECODE function Decodes Base64 encoded string.

Excel Formula:
=LAMBDA(x,
    LET(base64codes, {"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z";"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z";"0";"1";"2";"3";"4";"5";"6";"7";"8";"9";"+";"/"},
        inputStr, x,
        chars, MID(inputStr, SEQUENCE(,LEN(inputStr)),1),
        t, CONCAT(DEC2BIN(BYCOL(chars, LAMBDA(x, MATCH(TRUE, EXACT(x, base64codes),0)-1)), 6)),
        b, MID(t, SEQUENCE(,LEN(t)),1),
        r, WRAPROWS(b, 8, 0), 
        charDec, BYROW(r, LAMBDA(x, BIN2DEC(CONCAT(x)))),
        CONCAT(IFERROR(CHAR(charDec),""))
    )
)

Base64EncodeDecode.xlsx
AB
1Input StringLAMBDA Eecode
2U3VuSun
3T2ZmaWNlIENvbW11bmljYXRpb25zIFNlcnZlciAyMDA3Office Communications Server 2007
Sheet1
Cell Formulas
RangeFormula
B2:B3B2=BASE64DECODE(A2)
Lambda Functions
NameFormula
BASE64DECODE=LAMBDA(x, LET( base64codes, {"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z";"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z";"0";"1";"2";"3";"4";"5";"6";"7";"8";"9";"+";"/"}, inputStr, x, chars, MID(inputStr, SEQUENCE(,LEN(inputStr)),1), t, CONCAT(DEC2BIN(BYCOL(chars, LAMBDA(x, MATCH(TRUE, EXACT(x, base64codes),0)-1)), 6)), b, MID(t, SEQUENCE(,LEN(t)),1), r, WRAPROWS(b, 8, 0), charDec, BYROW(r, LAMBDA(x, BIN2DEC(CONCAT(x)))), CONCAT(IFERROR(CHAR(charDec),"")) ))
 
Upvote 0
The corrected function as @Xlambda suggested. Thanks again for taking the time to test the functions.

Excel Formula:
=LAMBDA(a, MAP(a,
LAMBDA(input, LET(
base64codes, {"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z";"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z";"0";"1";"2";"3";"4";"5";"6";"7";"8";"9";"+";"/"},
inputStr, SUBSTITUTE(input, "=", ""),
chars, MID(inputStr, SEQUENCE(, LEN(inputStr)), 1),
t, CONCAT(DEC2BIN(BYCOL(chars, LAMBDA(x, MATCH(TRUE, EXACT(x, base64codes), 0) - 1)), 6)),
b, MID(t, SEQUENCE(, LEN(t)), 1),
r, WRAPROWS(b, 8, 0),
charDec, BYROW(r, LAMBDA(x, BIN2DEC(CONCAT(x)))),
CONCAT(IFERROR(CHAR(charDec), ""))
))
))

Can a Moderator please edit the OP and correct the formula and add that the argument now can take a range of cells? Thanks
 
Here is the las correction. Now it decodes concatenated encoded strings correctly.

Excel Formula:
=LAMBDA(a, MAP(a,
LAMBDA(input, LET(
base64codes, {"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z";"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z";"0";"1";"2";"3";"4";"5";"6";"7";"8";"9";"+";"/"},
inputStr, SUBSTITUTE(input, "=", "A"),
chars, MID(inputStr, SEQUENCE(, LEN(inputStr)), 1),
t, CONCAT(DEC2BIN(BYCOL(chars, LAMBDA(x, MATCH(TRUE, EXACT(x, base64codes), 0) - 1)), 6)),
b, MID(t, SEQUENCE(, LEN(t)), 1),
r, WRAPROWS(b, 8, 0),
charDec, BYROW(r, LAMBDA(x, BIN2DEC(CONCAT(x)))),
CONCAT(IFERROR(CHAR(charDec), ""))
))
))
 

Forum statistics

Threads
1,224,836
Messages
6,181,251
Members
453,027
Latest member
Lost_in_spreadsheets

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top