Forum Discussion
TSmith98
Apr 30, 2021Copper Contributor
VBA Loop Code
Hello, I am a student struggling with some coding, I'm trying to run a loop inside of a loop so that the first loop goes down and the second goes across. Can someone please help me fix it? ...
- Apr 30, 2021
Is this better? Please check carefully.
TSmith98
Apr 30, 2021Copper Contributor
Hello,
I have attached the file
I have attached the file
HansVogelaar
Apr 30, 2021MVP
I would change
For i = 2 To MCLastRow
If Cells(i, 2).Value = "SBUB10" Then 'Code not recognising this 'Change to ending with 10
ErrorLogWS.Range("c" & i).Value = 40
ErrorLogWS.Range("D" & i).Value = 30
ElseIf Cells(i, 2).Value = "SBUB20" Or Cells(i, 2).Value = "SBUB30" Then
ErrorLogWS.Range("c" & i).Value = 30
ErrorLogWS.Range("D" & i).Value = 40
Else
End If
Next i
to
For i = 2 To MCLastRow
Select Case ErrorLogWS.Cells(i, 2).Value
Case "SBUB10" 'Code not recognising this 'Change to ending with 10
ErrorLogWS.Range("c" & i).Value = 40
ErrorLogWS.Range("D" & i).Value = 30
Case "SBUB20", "SBUB30"
ErrorLogWS.Range("c" & i).Value = 30
ErrorLogWS.Range("D" & i).Value = 40
End Select
Next i
This makes Cells(i, 2) explicitly refer to ErrorLogWS.
If the code still doesn't want what you do, please provide detailed information about the problem.
- TSmith98Apr 30, 2021Copper ContributorHey,
Thank you for this, but that part is working.
It is the section after that part that starts with:
''Code to find each semester and total credits'''
where there are two do loops- HansVogelaarApr 30, 2021MVP
And what exactly is the problem there?
- TSmith98Apr 30, 2021Copper ContributorMy goal is for the number of credits to be added to each B number but instead
All of the credits are being added to the first B number