Enter data from two cells in two other cells with (VBA-code assigned to) a shortcut

JohanXL

Board Regular
Joined
Jun 13, 2015
Messages
78
In columns C and D of my spreadsheet of car brands I have to enter brands, such as:

Column C Column D
BMW VOLVO
AUDI FIAT
VOLKSWAGEN RENAULT
PEUGEOT ALFA ROMEO

My data are such that some combinations, for instance BMW & VOLVO and VOLKSWAGEN & RENAULT have to be filled in much more often than for instance AUDI & FIAT or PEUGEOT & ALFA ROMEO.

Is it possible to enter the frequent combinations BMW & VOLVO and VOLKSWAGEN & RENAULT in a fast way? I would like to avoid having to cut and paste the combination BMW & VOLVO from A1 and B1 (which contain these brands) and paste it in C1 and D1, then to cut and paste VOLKSWAGEN & RENAULT from A2 and B2, paste it in C2 and D2, then back again to A1 and B1, etc.

Is it possible to use VBA-code assigned to shortcuts for this? For instance: Ctrl+a is Cut the contents from A1 and B1 and paste it from active cell C[n] into C[n] *and* D[n}, Ctrl+b is Cut the contents from A2 and B2 and paste it from active cell C[n] into C[n] *and* D[n}? Would it be possible maybe by first CONCATENATING the contents of A1 and B1 in another cell, for instance (F[n]), and then DE-CONCATENATE the CONCATENATED brandnames (BMWVOLVO, VOLKSWAGENRENAULT) and place the two different brand names (BMW and VOLVO) in C[n] and D[n]?

Thanks in advance,
JohanXL
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I suggest doing this.
1.Select column “C”
2. From the ribbon select “Data”
3. Select “Data Validation
4. Select “List”
5. Click in "Source"
6. Select the list of values in Column “A” on the sheet
7. Choose “OK”
8. Now right click on your sheet tab
9. Choose “View code”
10. Paste in the below script
Now when you want to enter “BMW” into a cell in Column “C” just choose from the drop down list and “BMW” should be entered in your cell and “VOLVO” should be entered in Column “D”

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("C:C")) Is Nothing Then

If Target.Value = "BMW" Then Target.Offset(0, 1).Value = "VOLVO"
If Target.Value = "AUDI" Then Target.Offset(0, 1).Value = "FIAT"
If Target.Value = "VOLKSWAGEN" Then Target.Offset(0, 1).Value = "RENAULT"
If Target.Value = "PEUGEOT" Then Target.Offset(0, 1).Value = "ALFA ROMEO"

'ADD MORE HERE IF YOU LIKE SEE SAMPLE BELOW
'If Target.Value = "FORD" Then Target.Offset(0, 1).Value = "BRONCO"
'REMOVE THE ' AT BEGINING OF LINE TO ACTIVATE THAT LINE.
End If
End Sub
 
Last edited:
Upvote 0
I suggest doing this.
1.Select column “C”
2. From the ribbon select “Data”
3. Select “Data Validation
4. Select “List”
5. Click in "Source"
6. Select the list of values in Column “A” on the sheet
7. Choose “OK”
8. Now right click on your sheet tab
9. Choose “View code”
10. Paste in the below script
Now when you want to enter “BMW” into a cell in Column “C” just choose from the drop down list and “BMW” should be entered in your cell and “VOLVO” should be entered in Column “D”

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("C:C")) Is Nothing Then

If Target.Value = "BMW" Then Target.Offset(0, 1).Value = "VOLVO"
If Target.Value = "AUDI" Then Target.Offset(0, 1).Value = "FIAT"
If Target.Value = "VOLKSWAGEN" Then Target.Offset(0, 1).Value = "RENAULT"
If Target.Value = "PEUGEOT" Then Target.Offset(0, 1).Value = "ALFA ROMEO"

'ADD MORE HERE IF YOU LIKE SEE SAMPLE BELOW
'If Target.Value = "FORD" Then Target.Offset(0, 1).Value = "BRONCO"
'REMOVE THE ' AT BEGINING OF LINE TO ACTIVATE THAT LINE.
End If
End Sub

Thank you very much for your reaction My Answer Is This, with apologies for the late reply!

Best,
JohanXL
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,496
Members
449,089
Latest member
Raviguru

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