+ Reply to Thread
Results 1 to 4 of 4

Arrange Data

  1. #1
    Registered User
    Join Date
    05-07-2009
    Location
    Illinois, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Arrange Data

    I have a file (working.xlsm) in which I need to move information from one place to another.

    The data that needs to be moved can be found in Y2:AW1220

    All data must stay in the row it originated in.

    The numerical value preceding the string must be transfered to the column associated with the string. (ie. Y2 should be moved to V2)

    I can manually go back and delete the originating information. So clean up is not an issue just the transfer of data.
    Attached Files Attached Files

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Arrange Data

    Hi RemyD, and welcome to the forum.

    If you put this formula in cell I2:

    =IF(ISNA(INDEX($Y2:$AV2,MATCH("*"&I$1&"*",$Z2:$AW2,0))),"",INDEX($Y2:$AV2,MATCH("*"&I$1&"*",$Z2:$AW2,0)))

    and then fill that right to cell X2, and then down to row 1220, you should get the results you're after. I hope.

    Make SURE your column headers in columns I:X are what you would find in the data from Y:AW. For example, the header in column S is "Hit roll", but in your data range only "hit" appears in cells. My formula won't find that as a match since it's looking for a match to *hit roll* not just *hit*. (Column T is the same, change "damage roll" to "damage" and it will return the correct results. There may be other column headers that need adjusting, too.)

    Once you're sure the numbers have calculated correctly, you can't just delete columns Y:AW. You could hide those columns, or you could copy I2:X1220 and use PasteSpecial -> Values on top of itself to convert the formulas to static numbers. You'd lose all your formulas, obviously, but it would allow you to delete Y:AW.

  3. #3
    Registered User
    Join Date
    05-07-2009
    Location
    Illinois, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Arrange Data

    Wow thanks Paul! When you get some time could you explain how that formula works? I will be in the help files in the meantime trying to understand it.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Arrange Data

    I'll give it a shot...

    You'll notice that the basic format is just an IF statement, and the test is to see if my formula (in red) returns the N/A error using the ISNA() function (in green). If so, it returns a blank, "".

    =IF(ISNA(INDEX($Y2:$AV2,MATCH("*"&I$1&"*",$Z2:$AW2,0))),"",INDEX($Y2:$AV2,MATCH("*"&I$1&"*",$Z2:$AW2 ,0)))

    The main formula, INDEX($Y2:$AV2,MATCH("*"&I$1&"*",$Z2:$AW2 ,0) is where the work is done. Normally an INDEX/MATCH function is used for matching a value and then returning an associated value from another column in the same row (or another row in the same column).

    In this case our two ranges overlap, being offset by 1 column. The MATCH values (what you're looking for) start in column Z, while the INDEX values (the values you want to return) start in column Y. So we're matching a value (the headers in columns I through X), using wildcards (asterisks), with the cell values in columns Z through AW. If a match is found, the INDEX portion then returns the value of the cell next to it due to the one column offset in the formula.

    It's a bit difficult to explain, but hopefully that gives you a good idea of what I was trying to accomplish.

    Note that in Excel 2007, there is a new IFERROR formula, so you could even shorten this to:

    =IFERROR(INDEX($Y2:$AV2,MATCH("*"&I$1&"*",$Z2:$AW2,0)),"")
    Last edited by Paul; 05-07-2009 at 02:02 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1