VBA: Copy cell and paste location changes via drop down menu

mohammadhdr

New Member
Joined
Aug 26, 2021
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Hi All,

I have a data analysis sheet that Im currently working on. I have a drop down list with different entries and I want my code to a copy specific cells (C102:G105) and depending on the drop down menu selection change the paste location of cell in different sheet. I have some of the code already done but it simply copies the cell and pastes it in a certain location in a different. If someone could help me out I would really appreciate it. Here is the code:

Private Sub Save()
Application.ScreenUpdating = False
Dim xSWName As String
Dim xSheet As Worksheet
Dim xPSheet As Worksheet
xSWName = "Results"
On Error Resume Next
Application.ScreenUpdating = False

Set xSheet = ActiveSheet


If xSheet.Name <> "Definitions" And xSheet.Name <> "fx" And xSheet.Name <> "Needs" Then

xSheet.Range("C102:G105").Copy
Set xPSheet = Worksheets.Item(xSWName)
xPSheet.Cells(5, 5).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If


Application.ScreenUpdating = True


End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
a good way to explain what I want is

IF cell C4 = E106
THEN
COPY C100:G103
AND
PASTE E5:I8

IF
IF cell C4 = E107
THEN
COPY C100:G103
AND
PASTE E9:I12

Hope that better explains what im looking for
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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