VBA code to compare data in two columns and update

Wafee

Board Regular
Joined
May 27, 2020
Messages
104
Office Version
  1. 2013
Platform
  1. Windows
Hi,

Have been trying to write a logic but not able to gte through, can someone help me with this.

I have below data in A & B columns of sheet1.

Book1
AB
1Senior ManagerManager
2GERMANOTTA, DOMINIC
3BONOMO, MICHAEL
4HALL, TAMARA L
5PRADHAN, JEETENDRA
6RANGARAJAN, JAGANNATH K
7STRATFORD, CHRIS
8STRATTON, LAURA M
9((blank)
10DINGARI, HRUSHIKESH K
11NAIR, GIRISH
12SARKAR, ASHIS
13VENKATRAMAN, SRINIVAS
14HUGHES, GEORGE L
15THAKER, DHAVAL V
16(blank)
17FAHEEM, WAEL
18AGARWAL, DINESH
19CHANDRASEKHARAN, RAJEEV
20CHANG, SOK WU W
21ZAVAR, MASTANEH
22WHITE, CHRIS L
23(blank)
24Grand Total
Sheet1



below data is in T & U columns of sheet 2.

Copy of Overall Shankar_Cox_UnapprovedTime Report.xlsm
TU
1Senior ManagerManager
2GURUMURTHY, VIVEKJAIN, ARCHANA
3ZIAEE, KAMRANKUMAR, NANDA
4GURUMURTHY, VIVEKBELIHOMJI, ADIL
5FAHEEM, WAELCHANDRASEKHARAN, RAJEEV
6GURUMURTHY, VIVEKJAIN, ARCHANA
7FAHEEM, WAEL(blank)
8ZIAEE, KAMRANCHAKRAVARTY, SHOMA
9GURUMURTHY, VIVEKBELIHOMJI, ADIL
10FAHEEM, WAELCHANDRASEKHARAN, RAJEEV
11GURUMURTHY, VIVEKBELIHOMJI, ADIL
12(blank)
13ZIAEE, KAMRAN(blank)
14(blank)
15GURUMURTHY, VIVEKBELIHOMJI, ADIL
16(blank)
17(blank)
18GURUMURTHY, VIVEKBELIHOMJI, ADIL
19GURUMURTHY, VIVEKJAIN, ARCHANA
20GURUMURTHY, VIVEKBELIHOMJI, ADIL
21FAHEEM, WAELWHITE, CHRIS L
22GURUMURTHY, VIVEKJAIN, ARCHANA
23GURUMURTHY, VIVEKBELIHOMJI, ADIL
24GURUMURTHY, VIVEKNIRANJANI, HIMANSHU
25GURUMURTHY, VIVEKJAIN, ARCHANA
Source Data



Code has to compare data in sheet 2 with sheet 1 and if any new senior manager is found then the name has to be updated in the "A" column of sheet 1 in the last before row that contains data(above "Grand Total").

if new manager is found then that name should be update under respective senior manager in sheet1.(in this case code has to check the combination of senior manager and manager as there might be case where manager moves from one senior manager to other - in that case new line to be added under the senior manager and it also retain old line for that manager ). thank you in advance.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hello Wafee

Isn't this discussing the same problem as you wrote about in your other posting at:


I think I answered your question there.
TotallyConfused
 
Upvote 0
Hello Wafee

Isn't this discussing the same problem as you wrote about in your other posting at:


I think I answered your question there.
TotallyConfused
No mate, the scenario is different and might require totally different logic than what I tried previously.
 
Upvote 0
If I remember correctly, you said then that your program worked, except it put the person's name AFTER the last row of data, instead of inserting a new row just above the last row. Now you are talking about columns 'A' and 'B' on the same sheet rather than columns 'A' on two sheets. Maybe I misunderstood your question then.
 
Upvote 0
If I remember correctly, you said then that your program worked, except it put the person's name AFTER the last row of data, instead of inserting a new row just above the last row. Now you are talking about columns 'A' and 'B' on the same sheet rather than columns 'A' on two sheets. Maybe I misunderstood your question then.
Yes That's right my requirement has changed now and I am finding it difficult to come up with a code.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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