I'm trying to AND two hex number bit-wise in Excel/Visual Basic.
Ex.
53FDBC AND 00FFFF
which should yield 00FDBC.
Any ideas on how to do this?
I'm trying to AND two hex number bit-wise in Excel/Visual Basic.
Ex.
53FDBC AND 00FFFF
which should yield 00FDBC.
Any ideas on how to do this?
iirc, it's built-in, only bit shifting operators are not built-in
&H53FDBC And &H00FFFF
I assume you have your 2 values stored as strings. In this case you could do the following:
Dim hex1 As String
hex1 = "53FDBC"
Dim hex2 As String
hex2 = "00FFFF"
Dim bin1 As String
bin1 = CLng("&H" & hex1)
Dim bin2 As String
bin2 = CLng("&H" & hex2)
Dim result As String
result = Hex$(bin1 And bin2)
result now contains "FDBC", but you may wish to pad this to the left with zeroes
As a function (excel module) this could be implemented as:
Function hexand(hex1 As String, hex2 As String) as String
Dim bin1 As String
bin1 = CLng("&H" & hex1)
Dim bin2 As String
bin2 = CLng("&H" & hex2)
hexand = Hex$(bin1 And bin2)
End Function