I am trying to go through a column of empty cells in my excel spreadsheet in order to find the row in which the word "Yes" is found. Afterwards, upon finding the word in a particular row, for instance in cell D23, I want it to go over one column to cell E23 and paste the value in that cell into cell B100. Here is what I have so far, but it doesn't seem to be functioning correctly:
Sub Test3()
Dim x As String
x = "Yes"
' Dim found As Boolean
' Select first line of data.
Range("D4").Select
' Set search variable value.
' Set Boolean variable "found" to false.
found = False
' Set Do loop to stop at empty cell.
Do Until ActiveCell.Value = x
' Check active cell for search value.
If ActiveCell.Value = x Then
Range("B100").Value = ActiveCell.Offset(0, 1).Value
found = True
Exit Do
End If
' Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select
Loop
' Check for found.
If found = True Then
MsgBox "Value found in cell " & ActiveCell.Address
Else
MsgBox "Value not found"
End If
End Sub
Thanks!