How to convert numbers between decimal and hexadecimal

To convert numbers between decimal and hexadecimal you use the equivalent Excel built-in function.

To convert from decimal to hexadecimal use the function DEC2HEX.

Syntax

DEC2HEX(number;places)

Number: The decimal number you want to convert into hexadecimal.

Places: Optional, the number of characters or positions to use. You can use this option to pad the return value with leading zeros. If number is negative, then the places parameter is ignored.

Examples:

1. A1 = 35; B1 = DEC2HEX(A1;4).

The returned vale in B1 will be 0023. Notice the leading zeros.

2. A1 = 1234; B1 = DEC2HEX(A1).

The returned vale in B1 will be 4D2.

To convert from hexadecimal to decimal use the function HEX2DEC.

Syntax

HEX2DEC (number)

Number: The hexadecimal number you want to convert into decimal. It cannot contain more than 10 characters.

 

Examples:

1. A1 = 100; B1 = HEX2DEC(A1).

The returned value in B1 will be 256.

2. A1 = FF25; B1 = HEX2DEC(A1).

The returned value in B1 will be 65317.

3. A1 = FFFFFFF6CC; B1 = HEX2DEC(A1).

The returned value in B1 will be -2356 (negative number).

 

Use INDEX and MATCH functions for table lookup

XL10Match1

  The table above lists some internet Top Level Domains (TLD) and their equivalent country codes. How can we look up the country name from the table if we know its TLD? E.g. we have the code “cn” and we want to know the corresponding … [Continue reading]

How to get the day of the week as text in Excel 2010

Excel WEEKDAY function will return the day of the week as a number. See details here: How-to-get-the-day-of-the-week-in-excel-2010 To return the day of the week as text (name of the day), we combine the WEEKDAY function with the TEXT function … [Continue reading]

How to get the day of the week in Excel 2010

To get the day of the week as a number you use Excel WEEKDAY function. Syntax WEEKDAY(serial_number,[return_type]) Serial number: a serial number that represent the date. Return type (optional): a number that determines how the weekday is … [Continue reading]

How to change the range of a defined name in Excel 2010

XL10EditName2

In a previous post I explained how to define named ranges in Excel 2010. OK, you have defined a name for a specified range. Later on you decided to change the size of that range either by expanding it or reducing it. Here is how you do it: 1. … [Continue reading]

How to define named ranges in Excel 2010

NamedRanges

If you have a range of cells that hold a specific type of data e.g. Sales, No. of students etc. then you can give that range a meaningful name. Later if you want to refer to the range you can do that by specifying its name instead of using its cell … [Continue reading]

How to calculate age in Excel 2010

To calculate a person (or anything else) age you basically subtract his date of birth from today’s date. However which date functions to use depends on the amount of precision and the output format you want. Suppose that we want to calculate the … [Continue reading]

New dynamic yearly calendar

I have added to the downloads page a new dynamic yearly calendar template.  You access the calendar through a user form which has two combo boxes: the first one to specify the year and the second  to select the start date of the week. You … [Continue reading]

How to protect VBA code in Excel 2010

XL10ProtectVBA1

If you have an EXCEL workbook that includes some VBA code, and you want to hide that code, either to protect your intellectual property or simply to prevent others from messing up your code accidently , then follow these steps: 1. In the … [Continue reading]

How to use colors in Excel 2010 VBA code

XL10Colorindex

If you want to use colors in your VBA macros e.g. to modify cell background color or to change the font color, then you have two options on how to specify the colors: 1. By choosing from one of the preset EXCEL colors (56 colors). You do this by … [Continue reading]