HomeGoogle DocsSpreadsheetMove Single Column to Multiple Columns Using Hlookup in Google Sheets

Move Single Column to Multiple Columns Using Hlookup in Google Sheets

Published on

To convert/move a single column to multiple columns, we can adopt different methods in Google Sheets.

Earlier I’ve shared two tutorials on the same or similar topic.

In the first one, I have used the Skipping (Clause) in Query, and in the other one, I’ve used the Split function.

Here are them.

But this time, we can learn how to move values in a single column to multiple columns using the Hlookup function in Google Sheets.

It seems more flexible than the other two.

To achieve our goal of converting single column values to multiple column values, I’m deviating a little bit from the real purpose of the Hlookup function, which is horizontal lookup, here.

Here also, we are using the Hlookup function for horizontal lookup. But our purpose is to move a single column value to multiple columns.

Let’s see how to move a single column value to multiple columns of our choice (‘N’) in Google Sheets.

For example, in the range A2:A, I have the month names from January to December.

I want to move these month names to 3 columns as below.

Moving Single Column to Multiple Columns

Let me take you to the solution.

Hlookup to Move Single Column to Multiple Columns

There are month names in A2:A.

I want to move these month names to 3 columns.

Here is the Hlookup formula (in cell C2 as per the image above) to do that.

Formula # 1:

=ArrayFormula(
     IFERROR(
        hlookup(
           "Test",
           {"Test";A2:A},
           SEQUENCE(roundup(COUNTA(A2:A)/3),3,2),
           0
        )
     )
)

You can do the same with any other values like strings, numbers, dates, or even mixed-type data in a single column.

Though Hlookup is the main formula, the Sequence function is equally important here.

In my formula above, it acts as the Hlookup ‘index’. How?

Syntax:

HLOOKUP(search_key, range, index, [is_sorted])

See the logic and formula explanation below.

Logic and Explanation

You won’t be able to correctly read my above formula if you are new to Hlookup. So you may try to understand it first.

Here is one example. The data range in use is A1:C4.

ABC
1Area 1Area 2Area 3
252030
3102535
4153040

Hlookup searches across the first row of a range, right?

Assume I want to search across row # 1 for the value “Area 1” and return all the values (5, 10, and 15) from the found column.

For this, we can use Hlookup as below.

Formula # 2:

=ArrayFormula(
     hlookup(
        "Area 1",
        A1:C4,
        {2;3;4},
        0
     )
)

In this {2;3;4} are the ‘index’ row (output row) numbers.

Please note that the first row in ‘range’ (A1:C4) is numbered 1. But I haven’t used {1;2;3;4} as the ‘index’ since I don’t want the value from the first row, i.e., the search key “Area 1”.

That means, by specifying row numbers as an array in the index, we can extract values from any rows using Hlookup.

I’ve used the same logic to convert/move a single column value to multiple column values in Google Sheets.

There I’ve specified the index row numbers as per my requirement that as a multiple columns array. That’s the logic part.

Now to the formula (Formula # 1) explanation.

Things I’ve Done

Our actual range is A2:A. I’ve changed it as {"Test";A2:A} which is the ‘range’ in Hlookup.

Since the first row of this range contains “Test,” the ‘search_key’ used in Hlookup is “Test,”

So that Hlookup can return values from this column (A2:A) as per our requirement (‘index’ array/matrix).

Now the Sequence part, the ‘index’ in Hlookup, is a combination formula.

SEQUENCE(roundup(COUNTA(A2:A)/3),3,2)

The COUNTA(A2:A) part in this formula returns the count of the values in A2:A.

Since we want to move the values from column A (single column) to 3 columns (multiple columns), I have divided the count result by 3. Then round up the number.

That means 12/3 = 4. So the result will be in 4 rows.

The rounding of the number is necessary to avoid issues in the case of decimal places after division.

As per Sequence syntax, the above formula output is the number of rows (4 rows) to return.

SEQUENCE(rows, [columns], [start], [step])

We want to move a single column value to 3 columns. So we should specify 3 as ‘columns’ in Sequence.

The ‘start’ value (the third argument in Sequence) must be 2 as the first value in the range is “Test,” which we want to omit.

The output of the above Sequence formula would be a 4 x 3 matrix as below.

Sequence in Hlookup Index Argument in Sheets

The above, the values highlighted in yellow, is the ‘index’ in Hlookup up.

That’s why the formula returns values from rows 2, 3, 4 in one row, 5, 6, 7 in another row, and so on.

Moving Single Column to Multiple N Columns and Defining N

To move a single column value to 5 columns, change the number 3 (all) in the above formula to 5. That’s all!

This way, we can move single column values to multiple columns in Google Sheets. Thanks for the stay. Enjoy!

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Running Total By Month in Excel

This tutorial demonstrates how to calculate the running total by month in a range...

SORT and SORTBY – Excel Vs Google Sheets

While Excel offers the SORT and SORTBY functions for sorting a table, Google Sheets...

Get Top N Values Using Excel’s FILTER Function

When using the FILTER function in Excel to extract the top N values, it's...

More like this

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.