Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Excel Vba help?

I want to take the column name of each column and associate that with the value under that column name. Each column will be different number of rows. There are x number of columns. So if the first column is D, the column name is let's say fruits and D2 is apple and D3 is banana. I want to have in A1 and A2 fruits and B1 as Apple and B2 be banana. Do it until all value have been first column is copied over to columns A and B, then move on to column E until all columns are done. Is there a way to do it excel without vba? If not, can you please provide the macro to this? Thanks in advance.

1 Answer

Relevance
  • Greg G
    Lv 7
    7 years ago

    You can use HLOOKUP for this.

    =HLOOKUP($A1, $D$1:$x$y, ROWS($A$1:A2), FALSE)

    Replace the x with the last column of your data table . Replace the y with the last row of your data table. So if your data went from D1 to Z15, use $Z$15.

    Copy down column B as far as you want.

    When you have all the "fruits" listed in B, change the value in column A to the value in E1 and start with the first formula again.

Still have questions? Get your answers by asking now.