vba compare between two sheets and highlight new items

leap out

Active Member
Joined
Dec 4, 2020
Messages
288
Office Version
  1. 2016
  2. 2010
Hi experts ,
I put the result in column column D,E for sheet2 and highlighted new item for sheet1,2
so current code compares data between two sheets based on column B , subtraction numeric values between two sheets and result show in column E for sheet2 , if the values are positive or negative then will be in column D wrong mark for adjacent cell and if the value is zero or empty in column E will be in column D right mark and if there new item is existed in sheet but it's not in the other will highlight the item by red . if the item is in existed in sheet1 , but it's not existed in sheet2 the value in column E is negative, if the item is in existed in sheet2 but not in sheet1 the value in column E is positive
so I want replace formula in column D with vba procedure and highlight new items between two sheets .
should copy highlighted data from sheet1 to sheet2 to become as I put in rang I: M but the result should be in range A:E
also posted here
vba compare between two sheets and highlight new items

VBA Code:
Sub UpdateSheet2()
Dim LR As Long

With Sheets("Sheet2")
    LR = .Range("B" & .Rows.Count).End(xlUp).Row
    With .Range("E2:E" & LR)
        .Formula = "=IF(ISNUMBER(MATCH(B2, Sheet1!B:B, 0)), C2 - VLOOKUP(B2, Sheet1!B:C, 2, 0), C2)"
        
        .Value = .Value

      
    End With
    
End With

End Sub


COMPARE.xlsm
ABC
1ITEMBRANDQTY
2110W40 208L55
3215W40 208L20
435W30 208L10
545W30 12x1L10
655W30 4x4L4
7610W40 12x4L45
8715W40 12x1L8
9810W40 12x1L1
10910W40 4x5L22
111010W40 4x1L20
12115W40 4x6L44
13125W40 4x4L20
14135W40 4x5L50
151420W50 4x4L9
161520W50 4x10L5
sheet1


COMPARE.xlsm
ABCDE
1ITEMBRANDQTYCONDITIONRESULT
2115W40 12x1L18û10
3210W40 12x1L40û39
4310W40 4x5L11û-11
5410W40 4x1L9û-11
655W40 4x6L4û-40
765W40 4x4L4û-16
875W40 4x5L45û-5
9820W50 4x4L8û-1
10910W40 208L1û-54
111015W40 208L33û13
12115W30 208L21û11
13125W30 12x1L10ü0
141320W50 4x1L4û4
sheet2
Cell Formulas
RangeFormula
D2:D14D2=IF(E2=0,CHAR(252),CHAR(251))



final result


COMPARE.xlsm
ABCDE
1ITEMBRANDQTYCONDITIONRESULT
2115W40 12x1L18û10
3210W40 12x1L40û39
4310W40 4x5L11û-11
5410W40 4x1L9û-11
655W40 4x6L4û-40
765W40 4x4L4û-16
875W40 4x5L45û-5
9820W50 4x4L8û-1
10910W40 208L1û-54
111015W40 208L33û13
12115W30 208L21û11
13125W30 12x1L10ü0
141320W50 4x1L4û4
15145W30 4x4L4û-4
161510W40 12x4L45û-45
171620W50 4x10L5û-5
sheet2
Cell Formulas
RangeFormula
D2:D17D2=IF(E2=0,CHAR(252),CHAR(251))
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi,
For your very "oily" question, do you have unique items in Both your Columns B in Sheet1 and Sheet2 ???
 
Upvote 0
do you have unique items in Both your Columns B in Sheet1 and Sheet2 ???
as you see all of matching based on brands in column B between two sheets . why is it problem for you to understand my requirements ?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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