VBA Loop and paste cell value based on IF condition

alqulal

New Member
Joined
Oct 20, 2021
Messages
4
Office Version
  1. 365
Platform
  1. MacOS
Hi, I am a beginner trying to understand vba and excel code. Currently, I have two separate workbooks A and B.
Say workbook A contains one individual customer info, and workbook B contains the compiled list of customers. I wish to check if workbook A customer ID (e.g., cell value A2) exists in any of the list of customer IDs in column A in workbook B. If it does, then I will copy a value like B2 in workbook A over to the row of that particular customer in workbook B column B. Would like to seek help in working around this.
Any help would be greatly appreciated.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I see your new to the forum so glad to see you here:
To be able to provide help we need specific details:

Like:
1. Both Workbook names with extensions
2. The sheet names on both workbooks we will be dealing with.
3. Both workbooks will need to be open
4. Remember specific details are a must. We only know what you tell us
 
Upvote 0
I see your new to the forum so glad to see you here:
To be able to provide help we need specific details:

Like:
1. Both Workbook names with extensions
2. The sheet names on both workbooks we will be dealing with.
3. Both workbooks will need to be open
4. Remember specific details are a must. We only know what you tell us
Hi, thanks for the inputs, with regards to the specifications - this is an example of what I'm working with.

'Customer Info' Workbook, 'Customer' sheet
Customer NameJohn
Customer ID456

as well as 'Compiled Customer' Workbook, 'Compilation' sheet (full table is 1000+ rows long)
IDName
123
456
789

As you can see, the 'Name' column is empty. Therefore, would wish to cross-check if the ID in 'Customer Info' workbook matches in 'Compiled Customer', and if it does, copy the Customer Name into the corresponding row.

If able, my preference is that 'Compiled Customer' workbook has to be open, but 'Customer Info' workbook does not and has to be activated.
Many thanks in advance!
 
Upvote 0
I asked several questions earlier but your answers were not complete:
I asked for both workbook names:
You should say something like this:

Alpha.xlsm

And I asked for sheet names:

All you showed was:
Customer Info' Workbook, 'Customer' sheet

Not sure what that means.

And you said:
If able, my preference is that 'Compiled Customer' workbook has to be open, but 'Customer Info' workbook does not and has to be activated.

A workbook cannot be activated if it's not open.

And to open a workbook using a script would require the exact path to the workbook

And the folder name where the workbook is stored.

You said:
Hi, I am a beginner trying to understand vba and excel code. Currently, I have two separate workbooks A and B.

Being a beginner to Excel I'm surprised your attempting to do a task like this.
 
Upvote 0

Forum statistics

Threads
1,224,735
Messages
6,180,636
Members
452,992
Latest member
TokugawaIesuma

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