RAJESH1960
Banned for repeated rules violations
- Joined
- Mar 26, 2020
- Messages
- 2,313
- Office Version
- 2019
- Platform
- Windows
Hello guys
With this code, I am getting the same message "Matched" even if it is "Mismatch". Please guide me to correct the code.
With this code, I am getting the same message "Matched" even if it is "Mismatch". Please guide me to correct the code.
Rich (BB code):
Option Explicit
Sub test()
Dim r As Long
Dim cnt As Long
cnt = 0
Application.ScreenUpdating = False
r = Cells(Rows.Count, 6).End(3).Row - 2
[g1] = "Check"
[g2] = "=F2"
[g3].Resize(r) = "=G2+D3-E3"
[H1] = "=IF(F" & r + 2 & "=G" & r + 2 & ",""Matched"",""Mismatch"")"
[h2].Resize(r + 1) = "=F2=G2"
[g1].Resize(, 2).Font.Bold = True
Columns("G:H").AutoFit
Application.ScreenUpdating = True
Select Case cnt
Case 1
Range("H1").Activate
MsgBox "MisMatch."
Case Else
Range("H1").Activate
MsgBox "Matched"
End Select
Range("H1").Activate
End Sub
Query code to check and match.xlsm | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | |||
1 | Dr Amount | Cr Amount | Balance | Check | Mismatch | |||||
2 | 1890.00 | 20091859.95 | 20091859.95 | TRUE | ||||||
3 | 13000.00 | 20078859.95 | 20078859.95 | TRUE | ||||||
4 | 4750.00 | 20074109.95 | 20074109.95 | TRUE | ||||||
5 | 326.00 | 20073783.95 | 20073783.95 | TRUE | ||||||
6 | 20063783.95 | 20073783.95 | FALSE | |||||||
7 | 22000.00 | 20041783.95 | 20051783.95 | FALSE | ||||||
8 | 21484.00 | 20020299.95 | 20030299.95 | FALSE | ||||||
9 | 8361.00 | 20011938.95 | 20021938.95 | FALSE | ||||||
10 | 7925.00 | 20004013.95 | 20014013.95 | FALSE | ||||||
11 | 3000.00 | 20007013.95 | 20017013.95 | FALSE | ||||||
12 | 20000.00 | 20027013.95 | 20037013.95 | FALSE | ||||||
13 | 15000.00 | 20042013.95 | 20052013.95 | FALSE | ||||||
14 | 673.00 | 20041340.95 | 20051340.95 | FALSE | ||||||
15 | 10044.00 | 20031296.95 | 20041296.95 | FALSE | ||||||
16 | 7000.00 | 20024296.95 | 20034296.95 | FALSE | ||||||
Match |
Cell Formulas | ||
---|---|---|
Range | Formula | |
H1 | H1 | =IF(F16=G16,"Matched","Mismatch") |
G2 | G2 | =F2 |
H2:H16 | H2 | =F2=G2 |
G3:G16 | G3 | =G2+D3-E3 |