If/then copy adjacent and paste value to adjacent on two different sheets

jerry1992

New Member
Joined
Sep 13, 2021
Messages
8
Office Version
  1. 2019
Platform
  1. Windows
Thanks for your help in advance I'm still very new to vba.

If I have data on sheet3 that I want to copy and paste in a specific cell on sheet1 how would I go about doing that for a specific
area of cells

Basically I need this.

if any cell in A2-33 on sheet1 equals any cell in E2-400 on sheet3 then copy whatever is in the cell next to cell E?(sheet3) in cell F?(sheet3)
and paste the value into the cell next to A?(sheet1) in cell B?(sheet1)

? being the row number where they match.

It has to be a value paste as well

so I guess something like this?

E?(sheet3)=A?(sheet1) so copy F?(sheet3) and paste value in B?(sheet1) .... but like in VBA :LOL:

Thanks so much. I usually just search forums where someone is trying to do something similar and adjust their code to work for my workbook but I'm having difficulty finding something similar to this.



Is this even possible?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Any particular reason why you want VBA? This can be done with a simple vlookup formula.
 
Upvote 0
Any particular reason why you want VBA? This can be done with a simple vlookup formula.
It is a macro I will end up attaching to a button with other macros to use in specific instances. At other times I will be pressing other buttons to clear the same cells and get different information to paste into the same cells I intend to use this for.
 
Upvote 0
Ok, how about
VBA Code:
Sub jerry()
   Dim Cl As Range
   Dim Dic As Object
   
   Set Dic = CreateObject("scripting.dictionary")
   With Sheets("Sheet3")
      For Each Cl In .Range("E2", .Range("E" & Rows.Count).End(xlUp))
         Dic(Cl.Value) = Cl.Offset(, 1).Value
      Next Cl
   End With
   With Sheets("Sheet1")
      For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
         If Dic.Exists(Cl.Value) Then Cl.Offset(, 1).Value = Dic(Cl.Value)
      Next Cl
   End With
End Sub
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,844
Members
449,051
Latest member
excelquestion515

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