Add another value from a cell onto the value from a data validation list

jamobe

New Member
Joined
Dec 23, 2014
Messages
36
Office Version
  1. 365
Platform
  1. Windows
Hi all

Could someone please help me with trying to achieve the below scenario

I have a colour in cell A2 ie blue, in cell A3 I have a data validation list with various selections, colour, month, size etc

When I select from the list in A3 I would like A3 to also have the value in A2 attached on the end so it will look like this in A3 'colour=blue.

Cheers!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You would need a worksheet change event for that.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
    If Target.Address(0, 0) = "A3" Then Target.Value = Target.Value & "=" & Range("A2").Value
Application.EnableEvents = True
End Sub
 
Upvote 0
Solution
You would need a worksheet change event for that.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
    If Target.Address(0, 0) = "A3" Then Target.Value = Target.Value & "=" & Range("A2").Value
Application.EnableEvents = True
End Sub
Thanks very much for that code. That seems very complex, for now I will just stick with having an extra column and using a formula in A4 like =A2&A3. Just out of interest, would that vba code slow the worksheet down for something achieving the same result with having an extra column? Or will it make no difference? My worksheet can become very slow due to the size of it so am curious.
 
Upvote 0
On something so simple the difference in speed would be too small to measure.

Bear in mind that it is only for a single cell (as per your question), if you wanted to apply the same rule to any cell in a specific column you may find that the vba method will be more efficient.
That said, slow performance would most likely be caused by other things. Excessively large arrays, heavy reliance on volatile functions, custom formats applied to large (unused) ranges, etc.
 
Upvote 0
On something so simple the difference in speed would be too small to measure.

Bear in mind that it is only for a single cell (as per your question), if you wanted to apply the same rule to any cell in a specific column you may find that the vba method will be more efficient.
That said, slow performance would most likely be caused by other things. Excessively large arrays, heavy reliance on volatile functions, custom formats applied to large (unused) ranges, etc.
Thanks that's interesting to know, it would actually be for many cells. I will look at using vba for things like this as with other functions I use on my worksheet.
 
Upvote 0
Thanks that's interesting to know, it would actually be for many cells.
In that case there would be things that might affect performance. As an example, for a continuous range of cells the Intersect method should be much faster than using If for each individual cell.
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,643
Members
449,093
Latest member
Ahmad123098

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