macro to check two data sets

ajaf123

New Member
Joined
Apr 19, 2015
Messages
33
hello. I have two sets of data bases both containing data with unique ID in column A.In ColumnB there are amounts (it varies how many amounts are with each ID). for example:
first data

<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>
</tbody>
A B C
1 id Amount Date
2 a112 200 dd-mm-yyy
3 1200 dd-mm-yyy
4 5 dd-mm-yyy
5 B112 500 dd-mm-yyy
6 400 dd-mm-yyy
7 C112 100 dd-mm-yyy

Second database:
A B C
1 id Amount Date
2 a112 1400 dd-mm-yyy
3
4 5
5
6
7 C112 100 dd-mm-yyy

I want a macro to match the sum of amounts with respective IDs and tick in the next column (columnE) when the sum of amounts equal. Also highlight in red if date with any ID of data2 is greater than that in data1.
 
Hi,
Well, if the structure of the database hasn’t changed, I mean, if the Id only appears once in column A with subsequent records in column B, there’s no reason for the macro to fail (theoretically it should have worked no matter if the entries in column A are text strings, numeric or alphanumeric).
However you could try using the CStr conversion function in order to ensure that the results correspond to the correct items.
Replace this part of the code:

Code:
Do Until ActiveCell.Row = LastRow + 1
If ActiveCell[B].Value[/B] <> ActiveCell.Offset(-1, 0).Value Then
Cells(ActiveCell.Row, 4) = Application.WorksheetFunction.SumIf(IdRng, [B]Cstr([/B]ActiveCell.Value[B])[/B], ValRng)
End If

If this adjustment doesn’t do the job, we could focus a little more in the details of the results distortion to get the source of the problem.
Hope it helps.
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,216,030
Messages
6,128,411
Members
449,449
Latest member
Quiet_Nectarine_

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top