Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got a handwritten list of about 500 coordinates for sprites on a sprite map in the form X1 Y1 Width Height

I need them outputted into a table with format {X1, Y1, X1+Width, Y1+Height}

I would like to make a VBA macro or something similar to input these numbers with just spaces between and the macro does the math and places them into a table with the above format for me - squiggly brackets included. Also, the table needs to be five coordinate sets wide before it drops down to a new row.

I started out trying to input the four numbers into a VBA input box, but apparently input boxes can only take one variable at a time. Having four separate input boxes pop up every time would drive me crazy and not save much time in the long run, so I need a new solution.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

How about entering them into a spreadsheet? You could have the x values in one column, the y in another, etc. Then in another column write a formula to combine them and output the format you want.

For example if you had a table like:

X   Y   Width   Height  Co-ords
3   4   21      13      {3, 4, 24, 17} 
2   6   78      45      {2, 6, 80, 51}

You could generate the Co-ords column with the following formula:

=CONCATENATE("{", A2, ", ", B2, ", ", (A2 +C2), ", ", (B2+D2), "}")

You can enter this in E2 and then fill down to apply to all cells in that column.

share|improve this answer
    
I like this idea Brad and will go forward with it, but is there a slick way to put it into a 5 by x table? –  Chris Mar 7 '13 at 0:54
    
Not sure if I follow your question. Do you mean put the X values in row 1, Y values in row 2, etc? –  Brad Patton Mar 7 '13 at 1:10
    
No I want it in a table with 5 columns basically –  Chris Mar 7 '13 at 1:49
    
Brad, I'm getting a #VALUE! Error with the format you have above. It seems fine to me, not sure what the problem is. –  Chris Mar 7 '13 at 1:55
1  
NP you can mark the answer as accepted if it solves your problem. –  Brad Patton Mar 7 '13 at 2:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.