Ok. I have the following code that keeps crashing Excel for me, but I can't figure out why. I have basically the same exact code that I have used multiple times with no problem.
Basically, I have last names and first names in two different workbooks, and if they equal each other, I want to copy the date of birth from the one workbook to other workbook.
Sub Macro4()
Dim iRow As Integer, cRow As Integer
iRow = 4
Dim wbC As Workbook, wbA As Workbook, wsC As Worksheet, wsA As Worksheet
Set wbC = Workbooks("Coventry Enroll Census 113014")
Set wbA = Workbooks("Copy of Ameritas Enroll Census Template 1 1 15 (2).xls")
Set wsC = wbC.Sheets(1)
Set wsA = wbA.Sheets(2)
Do: cRow = 2 'Reset cRow
'DOB
If wsC.Cells(cRow, 2) = wsA.Cells(iRow, 2) And wsC.Cells(cRow, 1) = wsA.Cells(iRow, 3)Then
wsC.Cells(cRow, 10).Select
Selection.Copy
Range(wsA.Cells(iRow, 6)).PasteSpecial (xlPasteValues)
iRow = iRow + 1
Else
cRow = cRow + 1
End If
Loop Until wsC.Cells(cRow, 1) = "" And wsC.Cells(cRow + 1, 1) = "" And wsC.Cells(cRow + 2, 1) = ""
End Sub