supermom28115
New Member
- Joined
- May 9, 2022
- Messages
- 43
- Office Version
- 365
- Platform
- Windows
VBA Code:
Public Sub birthLoops()
'this code checks for record and birth location notes and copies if needed
Dim x As Range, y As Range, record As Variant, birth As Variant
Dim startrow As Integer, i As Integer, endrow As Integer
endrow = Cells(Rows.Count, 14).End(xlUp).Row
For i = 3 To endrow
Set y = Cells(i, 14)
Set x = Cells(i, 13)
'for true answers it should evaluate the next line? for false it finds else or end and then the next line?
If IsEmpty(y(i, 14).Value2) Then 'this is supposed to look at the cell and say true to empty?
If LCase(x(i, 13).Value2) = "yes" Then 'this is supposed to look at the value of the cell and if they match say true?
Set birth = Range(y(i, 14).Offset(0, 2), y(i, 14).Offset(0, 4))
Set record = Range(y(i, 14).Offset(0, -4), y(i, 14).Offset(0, -2))
birth.Value = record.Value
End If
If LCase(y(i, 14).Value2) = "yes" Then
Else
y(i, 14).Value2 = "yes" 'this is the line, i thought it was not doing this step even though when i stepped through it was doing what i expected
End If 'and was evaluating and, i thought, processing the code. It was after about the 5th time of stepping through and the
'2nd time of running the code that I found yes printed in several rows on column AA.
End If
Next i
End Sub
I know it has other problems, specifically me having it start at the beginning of the column every time it runs but I just got so frustrated with trying to get the count rows code to work right. I still don't quite understand how the code process works for that particular issue. I don't mind it running repeatedly right now since I only have 10 rows of data right now. I think my row count is also adding a row every time it counts as well. I guess I should also say that I have this set as a table. I thought it would help with coding to be able to name ranges and have them automatically adjust as new records were added, however I ended up throwing the book across my house yesterday when I tried to use named ranges in the code. This is the dropbox link to the file as I am working on it now.