Hello, all,
I am working with the below code. I did not write the code, but I am commenting it so that others can understand what each line is doing (we are hiring a new person that has limited coding experience).
I would like to understand how rowRng is used in the code. Specifically, why does the Cells property remain unchanged (e.g. Cells(1,2) never changes), but rowRng changes? The code moves from one row to the next, so I don't understand why the Cells property isn't something like, Cells(x,2), where x changes with each loop. uniquecount is a function used to count the number of unique values in the column.
Here is the code:
Dim mapRng As Range
Dim tblQuestion As Range
Dim rowRng As Range
For Each rowRng In mapRng.Rows
If rowRng.Cells(1, 2) = "X" Then
rowRng.Cells(1, 3) = "X"
rowRng.Cells(1, 4) = "X"
Else
If rowRng.Cells(1, 2) > 0 And rowRng.Cells(1, 2) < 10000000 Then
If tblQuestion.Columns(1).Find(rowRng.Cells(1, 2)).Offset(0, 3) <> "" Then
rowRng.Cells(1, 3) = "QL"
Else
rowRng.Cells(1, 3) = "OPEN"
End If
Else
rowRng.Cells(1, 3) = "DEMO"
End If
If rowRng.Cells(1, 3) = "DEMO" Then
rowRng.Cells(1, 4) = rowRng.Cells(1, 2)
Else
If uniquecount(rowRng.Cells(1, 2), mapRng) = 1 Then
rowRng.Cells(1, 4) = "Main"
Else
rowRng.Cells(1, 4) = "TRANSPOSE"
End If
End If
End If
Next rowRng
Bookmarks