views:

916

answers:

6
+1  Q: 

Wrap rows in Excel

Let's say there is a report to compare charges with adjustments that outputs to excel, such that each row has the following fields:

  • Account Number
  • charge date
  • Original item number
  • Adjusted Item number
  • Original Qty
  • Adjusted Qty
  • Original amount
  • Adjusted amount
  • Original Post date
  • Adjusted Post date

I need to help a user create a view in Excel that helps them spot changes in each record. She wants it to show each record in two rows like this:

Account  |  Date  |  O. Item  |  O. Qty  |  O. Amount  |  O. Post
         |        |  A. Item  |  A. Qty  |  A. Amount  |  A. Post             

Is there anything built into Excel to allow you to group records like this? VBA is not an option in this case.

It's okay if the cells under account and date duplicate those values, if that makes it easier. Bonus points if you can get some kind of alternating row effect that helps delimit each record (that part I can do on my own in vba later if I have to).

+2  A: 
Tomalak
Gotcha. I get the concept. I can use the mod operator or integer division in a formula to calculate the row number in the source sheet from the target sheet. Thanks.
Joel Coehoorn
Yes. :-) That's what I would have done probably. If they would not have started down-voting me for not having excel code readily available in an SO-friendly manner. :-P
Tomalak
Okay, now how get excel to fill that formula in automatically?
Joel Coehoorn
Mark two rows at the same time, and pull them down until all input rows are covered. The range to mark-and-pull would be "A2:D3", in my above sample.
Tomalak
A: 

I think it is only possible with programming (hey, this is a programming-related site).

When VBA is not an option, is it allowed to use VB.Net or C#?

GvS
No macros here. It's not only that I have to set it up. I have to be able to show her how to set it up and repeat it in the future from different machines where the macro may not be available.
Joel Coehoorn
A: 

I've done exactly this in VBA a few years ago and it worked great, i guess you could do the samething using C# with Interops?

I could tell what was added, removed and changed. It create a report in the end which was easy to sort out and filter.

Is there a reason why VBA is not an option? And what other options are available?

you could also cross reference the data using Excel functions, but this can be quite complicated for someone who is not an excel power user. general help in excel formulas

Edit: you will need functions like Find Index Offset VLookup Match, this can all be done by combining them. the only drawback is that there is a limit to the formula length. When this limit is reached split the logic in multiple columns or rows.

Edit: you could intergrate the VBA in a single workbook, and have the template saved. each time they wish to compare they use this template to execute the comparisson. this way no deployment is required. they simply need to copy the file and use it.

Edit: The solution proposed by Tomalak may not work since when records are added or removed, we have no control on where these records will be positioned. you will need to find the row with a key match and work from there.

Alexandre Brisebois
See the comment to the above response. It's mostly just a deployment issue, but an issue nonetheless.
Joel Coehoorn
Also, a certain amount of irrational fear of vba among the powers that be where I'm at.
Joel Coehoorn
+1  A: 

A simple workaround might be to use Conditional Formatting (directions are for Office 2007):

  1. Highlight the "Adjusted" column (suppose, it's Column D and the Original was column C)
  2. Click "Conditional Formatting"
  3. Click "New Rule..."
  4. Click the last item "Usa a formula to determine which cells to format"
  5. Enter C1 <> D1
  6. Pick a formatting style.

Apply the rule, and all the entries that don't match will be highlighted in the style you selected.

grammar31
Most entries won't match. It's a complicated set of business rules that determine difference. For example, item 54321 might be the same thing a 6ct of item 54320, but with a special price. So in this case they're just checking the math on the whole row.
Joel Coehoorn
BTW: that particular example isn't good, because anything that simple was already culled from the report on the back-end.
Joel Coehoorn
+1  A: 

I also did this with Indirect. My formulas on the second sheet look something like:

=INDIRECT("source!A" & INT(ROW()/2)+1)

You will hard-code the letter to indicate the column source, and then the calculation will automatically choose from the correct row. Should copy down as far as you need.

BradC
A: 

Conditional formatting can do both jobs, because you can have up to 3 conditions per cell

  1. you can (say) use red bold text to highlight any cells which are different, using a validation formula like this

    eg =(DataA!C8 <> DataB!C8)

  2. you can shade alternate rows using a formula like this (as used in cell C8)

    eg =(MOD(CELL("Row",C8),2)=0)

which will shade even rows. To shade odd rows instead, of course, use =1 at the end of the formula instead of =0

dbb