I am comparing two sheets and their columns. My code runs. Problem is it compares most of the values and leaves some values though they are the same.
Sub Peformance()
Dim k As Integer
Dim i As Integer
Dim j As Integer
For i = 1 To 138
If (ActiveWorkbook.Worksheets("report").Cells(i, 6).Value = "course-1") Then
For j = 1 To 138
If (ActiveWorkbook.Worksheets("report").Cells(i, 1).Value = Cells(j, 1)) Then
Cells(j, 4).Value = (ActiveWorkbook.Worksheets("report").Cells(i, 12).Value) / 100
Cells(j, 5).Value = (ActiveWorkbook.Worksheets("report").Cells(i, 20).Value) / 100
Cells(j, 6).Value = (ActiveWorkbook.Worksheets("report").Cells(i, 13).Value)
End If
Next j
End If
Next i
For k = 1 To 138
If (IsEmpty(Cells(k, 4).Value)) Then
Cells(k, 4).Value = 0
Cells(k, 5).Value = 0
End If
If (IsEmpty(Cells(k, 6).Value)) Then
Cells(k, 6).Value = 0
End If
End Sub
In one file (sheet-2) I have students courses like course-1, course-2, course-3 etc.
In the other file (sheet-1) I have students names.
After comparing names (Column-1 of sheet-2 and sheet-1) I have to copy the performance from sheet-2 to sheet-1.
It runs but is not showing output for some students whose names are same.
Also how can I add the feature of case sensitive?
Sample Data
Sheet2:
| Name | External | Course | Course-ID | Course-Slug | Work-Percentage | |
|---|---|---|---|---|---|---|
| A | a@gmail.com | 12 | A | course | course-1 | 63% |
| B | b@gmail.com | 13 | A | course | course-1 | 19% |
Sheet1:
| Name | Work-Percentage |
|---|---|
| A | |
| B |
So sheet1 column Work-Percentage will copy data from Work-Percentage column after comparing the name and course-Slug from sheet-2