anewuser111
New Member
- Joined
- Jan 5, 2021
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
0
I am new to VBA. I'm writing a program where a macro scans the worksheet, each row is an application. The last column CR writes if the applicant is eligible or not based on some criteria.
I am trying to write a loop that goes through each applicant and checks for completeness. For one condition, it is "If the loop is on the cell that says Yes/No for funding (AT), and value of the cell is Yes, and the cell next to it is empty, then return for the final column (CR) that application is incomplete.
I have tried to implement that below but for some reason I am still getting complete when testing even when the applicant should be incomplete.
What is wrong with my code? Is it because the cells are comparing the values and not the ranges?
I am new to VBA. I'm writing a program where a macro scans the worksheet, each row is an application. The last column CR writes if the applicant is eligible or not based on some criteria.
I am trying to write a loop that goes through each applicant and checks for completeness. For one condition, it is "If the loop is on the cell that says Yes/No for funding (AT), and value of the cell is Yes, and the cell next to it is empty, then return for the final column (CR) that application is incomplete.
I have tried to implement that below but for some reason I am still getting complete when testing even when the applicant should be incomplete.
What is wrong with my code? Is it because the cells are comparing the values and not the ranges?
VBA Code:
For Each c In Range("B2:CI10").Cells
completeness = "CR" & c.row
Set completeness2 = Range(completeness)
fundingCell = "AT" & c.row
Set fundingCell2 = Range(fundingCell)
If (c = fundingCell And fundingCell2.Value = "Yes" And IsEmpty(c.Offset(0, 1))) Then
completeness2 = "incomplete"
Else
completeness2 = "Complete"
End If
Next
End Sub