Hello,

can someone explain this code to me? I have this file that has a macro button transferring all the information(KPI's to be exact) from a database worksheet to a viewing worksheet. On the viewing worksheet, you select a name of an employee and when you press the "load data" button, it transfers all the KPI for that specific employee. Any help would be great.

Private Sub cmdLoad_Click()

Dim i, j As Integer

j = wksPMP.Cells(4, 4) + 2

For i = 23 To 34

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i - 20)

Next i

For i = 40 To 51

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i - 25)

Next i

For i = 57 To 68

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i - 30)

Next i

For i = 74 To 85

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i - 35)

Next i

For i = 23 To 34

wksPMP.Cells(i, 8) = wksDatabase.Cells(j, i + 28)

Next i

For i = 40 To 51

wksPMP.Cells(i, 8) = wksDatabase.Cells(j, i + 23)

Next i

For i = 57 To 68

wksPMP.Cells(i, 8) = wksDatabase.Cells(j, i + 18)

Next i

For i = 74 To 85

wksPMP.Cells(i, 8) = wksDatabase.Cells(j, i + 13)

Next i

For i = 91 To 102

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i + 8)

Next i

End Sub

Private Sub cmdSave_Click()

Dim i, j As Integer

j = wksPMP.Cells(4, 4) + 2

For i = 23 To 34

wksDatabase.Cells(j, i - 20) = wksPMP.Cells(i, 3)

Next i

For i = 40 To 51

wksDatabase.Cells(j, i - 25) = wksPMP.Cells(i, 3)

Next i

For i = 57 To 68

wksDatabase.Cells(j, i - 30) = wksPMP.Cells(i, 3)

Next i

For i = 74 To 85

wksDatabase.Cells(j, i - 35) = wksPMP.Cells(i, 3)

Next i

For i = 23 To 34

wksDatabase.Cells(j, i + 28) = wksPMP.Cells(i, 8)

Next i

For i = 40 To 51

wksDatabase.Cells(j, i + 23) = wksPMP.Cells(i, 8)

Next i

For i = 57 To 68

wksDatabase.Cells(j, i + 18) = wksPMP.Cells(i, 8)

Next i

For i = 74 To 85

wksDatabase.Cells(j, i + 13) = wksPMP.Cells(i, 8)

Next i

End Sub

See more
can someone explain this code to me? I have this file that has a macro button transferring all the information(KPI's to be exact) from a database worksheet to a viewing worksheet. On the viewing worksheet, you select a name of an employee and when you press the "load data" button, it transfers all the KPI for that specific employee. Any help would be great.

Private Sub cmdLoad_Click()

Dim i, j As Integer

j = wksPMP.Cells(4, 4) + 2

For i = 23 To 34

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i - 20)

Next i

For i = 40 To 51

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i - 25)

Next i

For i = 57 To 68

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i - 30)

Next i

For i = 74 To 85

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i - 35)

Next i

For i = 23 To 34

wksPMP.Cells(i, 8) = wksDatabase.Cells(j, i + 28)

Next i

For i = 40 To 51

wksPMP.Cells(i, 8) = wksDatabase.Cells(j, i + 23)

Next i

For i = 57 To 68

wksPMP.Cells(i, 8) = wksDatabase.Cells(j, i + 18)

Next i

For i = 74 To 85

wksPMP.Cells(i, 8) = wksDatabase.Cells(j, i + 13)

Next i

For i = 91 To 102

wksPMP.Cells(i, 3) = wksDatabase.Cells(j, i + 8)

Next i

End Sub

Private Sub cmdSave_Click()

Dim i, j As Integer

j = wksPMP.Cells(4, 4) + 2

For i = 23 To 34

wksDatabase.Cells(j, i - 20) = wksPMP.Cells(i, 3)

Next i

For i = 40 To 51

wksDatabase.Cells(j, i - 25) = wksPMP.Cells(i, 3)

Next i

For i = 57 To 68

wksDatabase.Cells(j, i - 30) = wksPMP.Cells(i, 3)

Next i

For i = 74 To 85

wksDatabase.Cells(j, i - 35) = wksPMP.Cells(i, 3)

Next i

For i = 23 To 34

wksDatabase.Cells(j, i + 28) = wksPMP.Cells(i, 8)

Next i

For i = 40 To 51

wksDatabase.Cells(j, i + 23) = wksPMP.Cells(i, 8)

Next i

For i = 57 To 68

wksDatabase.Cells(j, i + 18) = wksPMP.Cells(i, 8)

Next i

For i = 74 To 85

wksDatabase.Cells(j, i + 13) = wksPMP.Cells(i, 8)

Next i

End Sub

Griever666- Feb 28, 2017 at 11:49 AM