# Sorting data in a table by date

#### teekayy

##### New Member
Hi All,

I have macro which creates a table and attaches it to an email. Is it possible to rearrange this data so that the table is essentially split into 2 tables, where the first part of the table show only the data from yesterdays date (column b), and then below this data there is a line that says "Running total" and then the data from all the other dates.

Here is the code:

Rich (BB code):
``````      a = Range("a1:a200000")
b = Range("b1:b200000")
d = Range("d1:d200000")
m = Range("m1:m200000")
f = Range("f1:f200000")
g = Range("g1:g200000")

jk = Range("j1:j200000")
n = Range("n1:n200000")

count1 = 0

ebody1 = "" + "" + "Deal Title" + ""

For i = 2 To 200000

If j(i) = 0 And a(i, 1) <> "" And CStr(f(i, 1)) <> "" Then

count = 0
count1 = 0
count2 = 0

For k = 2 To 200000

If CStr(g(k, 1)) = CStr(g(i, 1)) And j(k) = 0 And a(k, 1) <> "" And CStr(f(i, 1)) <> "" Then

count = count + 1

count2 = count2 + 1
j(k) = 1

ebody = CStr(n(k, 1)) + "" + ebody

End If

Next

ebody = ebody1 + ebody + "
" + "Contract ID" + "" + "Refund Date" + "" + "Deal ID" + "" + "Voucher Code" + "" + CStr(g(k, 1)) + "" + CStr(b(k, 1)) + "" + CStr(m(k, 1)) + "" + CStr(jk(k, 1)) + "

<tbody>

</tbody>"``````

Is this at all possible?

Thanks!

Tee

### Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
ahh Robert you beat me to it!

Can anyone assist? I was thinking if it is too complicated to do, maybe it is possible to highlight the rows in the table where the date (column b) is equal to yesterdays date?

Excel 03 formula<code>
=TODAY()-A1=1</code>
where A1 is the date of intrest then copy the format down.
In Excle 07/10 go to Conditional Formatting-->Higlight Cell Rules-->A Date Accuring...

Sheet2

 * A 3 * 4 18/06/2012 5 18/06/2012 6 * 7 * 8 * 9 20/06/2012 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 18/06/2012

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:75px;"></colgroup><tbody>
</tbody>

Excel tables to the web >> Excel Jeanie HTML 4

Replies
10
Views
658
Replies
9
Views
345
Replies
3
Views
333
Replies
1
Views
366
Replies
4
Views
681

### Forum statistics

1,196,073
Messages
6,013,275
Members
441,759
Latest member
ab_ ### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?    1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option. Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com". Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button. Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button. Go back