VBA; Replace cell content with B when A is selected

niicommey

New Member
Joined
Feb 3, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello, I am new using VBA. I have data in 2 columns A with corresponding data in B. I have used the data in column A as a drop down menu. I want an excel VBA code that will retrieve data from column B and use that to replace the data selected from A. A sample data is below
A
Blue
Green
Purple
Yellow
Red

B
Apple
Lemon
Banana
Orange
Melon

The vba should should replace Blue with Apple when I select Apple from the drop down list and Yellow with Orange
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
So are you saying the values in column A are from a DataValidation.list
And if you select Apple from the validation list you want this value changed to the data in column B same row?
That would not be possible using a sheet change again event script because the value now put in column A is not a value in the datavalidation list
 
Upvote 0
So are you saying the values in column A are from a DataValidation.list
And if you select Apple from the validation list you want this value changed to the data in column B same row?
That would not be possible using a sheet change again event script because the value now put in column A is not a value in the datavalidation list
Yes, the data in column A is from a Data Validation List. Is there no way it can be done? Because I don't need the new value which is from column B to be in the data validation list.
 
Upvote 0
Yes, the data in column A is from a Data Validation List. Is there no way it can be done? Because I don't need the new value which is from column B to be in the data validation list.
I think you said you had a Datavalidation list in column A is that correct?
And if you select "Cat" from the Datavalidation list you want "Cat" replaced with "Dog" which is in column B of same row.
Is this not correct?
 
Upvote 0
You said:
Because I don't need the new value which is from column B to be in the data validation list.
So what do you want to happen?
 
Upvote 0
If we enter the value in column B into same cell in column A it really does not change the Datavalidation list which is somewhere else. But a message box will pop up saying that is not a valid entry.
 
Upvote 0
If we enter the value in column B into same cell in column A it really does not change the Datavalidation list which is somewhere else. But a message box will pop up saying that is not a valid entry.
Ok. I will then have to find another way.
 
Upvote 0

Forum statistics

Threads
1,214,535
Messages
6,120,093
Members
448,944
Latest member
SarahSomethingExcel100

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