Reputation: 29
Think this should be straight forward for everyone. So as the title says, i would like to know the easiest way to achieve below :
If cell A1 on sheet1 contains X then copy A1 from sheet2 to cell A2 on sheet 1
many thanks!
Upvotes: 0
Views: 1637
Reputation: 3801
This does exactly as the question asks.
Sub copyStuff()
If Sheets("Sheet1").Range("A1") = "X" Then
Sheets("Sheet1").Range("A2") = Sheets("Sheet2").Range("A1")
End If
MsgBox "Next time I will provide an example"
End Sub
Upvotes: 1
Reputation: 98
If your looking for a macro i am assuming this is what your asking for.
Sub Test
IF Sheet1.Range("A1").value = "X" then Sheet1.Range("A2").value = Sheet2.Range("A1").value
End sub
Have a great day!
Upvotes: 0
Reputation: 251
You could set up a formula in cell A2 on Sheet1 like this:
=IF(ISNUMBER(SEARCH("X", A1)), Sheet2!A1, "NOT FOUND")
Changing "X" to whatever you want your text to be.
SEARCH will look for text "X" in cell A1, and ISNUMBER will check if SEARCH returned the index of where the text was found in the cell. If it was not found, it will print "NOT FOUND"
Upvotes: 0