Hello VBA experts.
I am looking for some VBA expertise.
I have external reference cells (vlookups) in the destination file that links to the source file. I am looking for a code where anytime a cell value changes in the source file, the external reference cells in the destination file will get highlighted yellow and stay highlighted yellow. If no cell value changes in the source file, the code will skip and move on to the next cell. Any expertise is greatly appreciated. I was thinking worksheet_calculate or worksheet_change event would work but I don't know what code to use to lookup cells in the source file.
Illustration below: The first table is the destination file. The second table below is the source file.
[TABLE="width: 440"]
[tr]
[td]
ID
[/td]
[td]
LookupValue1
[/td]
[td]
LookupValue2
[/td]
[td]
LookupValue3
[/td]
[td]
LookupValue4
[/td]
[/tr]
[tr]
[TD="align: right"]8020456
[/TD]
[TD="align: right"]20
[/TD]
[TD="align: right"]25
[/TD]
[TD="align: right"]5
[/TD]
[TD="align: right"]1000
[/TD]
[/tr]
[tr]
[TD="align: right"]8020457
[/TD]
[TD="align: right"]999
[/TD]
[TD="align: right"]15
[/TD]
[TD="align: right"]60
[/TD]
[TD="align: right"]2000
[/TD]
[/tr]
[tr]
[TD="align: right"]8020458
[/TD]
[TD="align: right"]70
[/TD]
[TD="align: right"]30
[/TD]
[TD="align: right"]25
[/TD]
[TD="align: right"]6000
[/TD]
[/tr]
[tr]
[TD="align: right"]8020459
[/TD]
[TD="align: right"]60
[/TD]
[TD="align: right"]20
[/TD]
[TD="align: right"]80
[/TD]
[TD="align: right"]7000
[/TD]
[/tr]
[tr]
[TD="align: right"]8020460
[/TD]
[TD="align: right"]50
[/TD]
[TD="align: right"]25
[/TD]
[TD="align: right"]90
[/TD]
[TD="align: right"]9999
[/TD]
[/tr]
[/TABLE]
[TABLE="width: 440"]
[tr]
[td]
ID
[/td]
[td]
CellChange
[/td]
[td]
CellChange
[/td]
[td]
CellChange
[/td]
[td]
CellChange
[/td]
[/tr]
[tr]
[TD="align: right"]8020456
[/TD]
[TD="align: right"]20
[/TD]
[TD="align: right"]25
[/TD]
[TD="align: right"]5
[/TD]
[TD="align: right"]1000
[/TD]
[/tr]
[tr]
[TD="align: right"]8020457
[/TD]
[TD="align: right"]999
[/TD]
[TD="align: right"]15
[/TD]
[TD="align: right"]60
[/TD]
[TD="align: right"]2000
[/TD]
[/tr]
[tr]
[TD="align: right"]8020458
[/TD]
[TD="align: right"]70
[/TD]
[TD="align: right"]30
[/TD]
[TD="align: right"]25
[/TD]
[TD="align: right"]6000
[/TD]
[/tr]
[tr]
[TD="align: right"]8020459
[/TD]
[TD="align: right"]60
[/TD]
[TD="align: right"]20
[/TD]
[TD="align: right"]80
[/TD]
[TD="align: right"]7000
[/TD]
[/tr]
[tr]
[TD="align: right"]8020460
[/TD]
[TD="align: right"]50
[/TD]
[TD="align: right"]25
[/TD]
[TD="align: right"]90
[/TD]
[TD="align: right"]9999
[/TD]
[/tr]
[/TABLE]
Here is the code that I created to start conversations and hopefully solve this post.
Private Sub Worksheet_Calculate()
dim prevvalu as integer
application.calculation = x1caculationmanual
if target.column >= 10 and target.column <=13 then
if target("a1").value <> prevvalu then
range.interior.color index = 36
end if
end if
Display More
end Sub