VBA copy/paste cells based on dropdown selection

Mmcq16

New Member
Joined
Apr 11, 2013
Messages
9
Hello

I have two sheets that I am using. sheet 2 has a list of experiments in column C with information regarding the experiment in columns F - J. On sheet 1 I have a dropdown box with a list of all the experiments. When I select an experiment from the dropdown box I would like to populate columns K - O on sheet 1 with the information from columns F - J for the selected experiment on sheet 2. Is this possible?. Any help would be apprecicated

-
Mike
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
What is the cell location of your drop down list in sheet 1?
 
Upvote 0
Place the following code into the code module for sheet 1 (not into a regular module).
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("D:D")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim bottomC As Long
    bottomC = Sheets("Sheet2").Range("C" & Rows.Count).End(xlUp).Row
    Dim x As Long
    For x = bottomC To 2 Step -1
        If Sheets("sheet2").Cells(x, 3) = Target Then
            Sheets("Sheet2").Cells(x, 6).Resize(, 5).Copy Cells(Target.Row, 11)
        End If
    Next x
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi, I have a quick followup question. If I would want to type a new experiment in the dropdown box and fill in new data manually, only on sheet 1, how would I amend the code to allow this without coming up with a runtime type mismatch error?
 
Upvote 0
Hi Mike. Do you mean that you want to add a new experiment in the drop down list but that experiment does not exist in column C of sheet 2?
 
Upvote 0
Try putting this line:
Code:
On Error Resume Next
below this line:
Code:
For x = bottomC To 2 Step -1
Please let me know if that works.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

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