Hi,
I'm trying to create an excel sheet whereby when the user changes the value of column A3 in one Worksheet "ViewResponses", excel searches Column A in another Worksheet "QuestionsDB", starting at B4, for a matching value. If it finds this value in a cell it then copies the contents of the adjacent cell in column C to a cell in "ViewResponses." This continues till all items in Column B of QuestionsDB have been checked against the value of A3.
I created a Do..Loop with an If statement to try and get this done but it is crashing my excel.
Please Help, code is below
Private Sub Worksheet_Change(ByVal Target As Range)
Dim dataRow As Long
Dim outputRow As Long
Dim wsDB As Worksheet
Dim wsOutput As Worksheet
Set wsDB = Sheets("QuestionsDB")
Set wsOutput = Sheets("ViewResponses")
If Target.Address = "$A$3" Then
Application.EnableEvents = False
dataRow = wsDB.Range("A4").Row
outputRow = wsOutput.Range("A5").Row
Do
If wsOutput.Range("A3").Value = wsDB.Range("B" & dataRow).Value Then wsOutput.Range("A" & outputRow).Value = wsDB.Range("C" & dataRow).Value
dataRow = dataRow + 1
outputRow = outputRow + 1
End If
Loop Until IsEmpty(Sheets("QuestionsDB").Cells(dataRow, 1))
Application.EnableEvents = True
End If
End Sub
Bookmarks