I'm wondering about how to use "worksheet-change" the best way possible. Right now I use it to copy from one column to another column, in two different sheets. Whenever the column in Sheet1 is updated, column in Sheet2 will as well be updated. Using two columns is no problem and the code works fine!
My issue is whenever I want to use three columns. I want it to loop through column A and whenever it finds the word "Orange" in it, it should copy column B to coulmn A in sheet2.See my sheet for more detailed information.
If it finds Orange, it should only copy and updated the values "1,3,6" in Column B to column A in sheet2.
A code I tried with but didn't work, it copied everything to column B. If it is possible to use VLOOKUP, how do I do that? Because I tried that but it didnt updated whenever a cell was changed.
Dim x As Range
With Sheets("Sheet1")
Set x = .Columns(1).Find("Orange", LookIn:=xlValues, lookat:=xlWhole)
If Not x Is Nothing Then
.Columns(2).Copy Sheets("Sheet2").[B1]
End If
Set x = Nothing
End With
Example:
Workbook 1: Column A
- Orange
- apple
- Orange
- Pear
- Berry
- Orange
Column B:
- 1
- 2
- 3
- 4
- 5
- 6
Should populate into a new sheet where only "1,3,6" is pasted in column B sheet2