VBA copy and paste into specific row based on drop down and specific column

DNicole

New Member
Joined
Feb 21, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am new to VBA and trying to write the code to do the following. In sheet1 D7 I have a drop down to select a project name and then in D14 and D17 two other drop downs for yes or no answers. In sheet 2 I have all the projects listed in column A and then various other information in the other columns. I want it to match sheet1 D7 with the correct row in sheet2 based on the project name in column A and then paste the values in D14 and D17 to columns E and I in sheet 2
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi Nicole,
Try this
After running VBA code below:
VBA Code:
Sub Match_And_Copy()
    Dim MtchVal As Long
    MtchVal = Application.WorksheetFunction.Match(Range("Sheet1!D7"), Range("Sheet2!A2:A15"), 0)
    Range("Sheet2!E1").Offset(MtchVal).Value = Range("Sheet1!D14").Value
    Range("Sheet2!I1").Offset(MtchVal).Value = Range("Sheet1!D17").Value
End Sub
According to your selection on D7 in sheet1 (in my example: "Project_29", the values from D14 & D17 from sheet1, will go to columns E and I, sheet2
Sheet-1.jpg
Sheet-2.jpg
 
Upvote 0
Hi Nicole,
Try this
After running VBA code below:
VBA Code:
Sub Match_And_Copy()
    Dim MtchVal As Long
    MtchVal = Application.WorksheetFunction.Match(Range("Sheet1!D7"), Range("Sheet2!A2:A15"), 0)
    Range("Sheet2!E1").Offset(MtchVal).Value = Range("Sheet1!D14").Value
    Range("Sheet2!I1").Offset(MtchVal).Value = Range("Sheet1!D17").Value
End Sub
According to your selection on D7 in sheet1 (in my example: "Project_29", the values from D14 & D17 from sheet1, will go to columns E and I, sheet2
View attachment 58588View attachment 58589
Thank you this is exactly what I needed!
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,525
Members
448,969
Latest member
mirek8991

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