Need Help with my VBA code as I am super lost

danielemusu

New Member
Joined
Jun 20, 2022
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
I need help. I need to write a VBA code where I need to match an ID number from the answer sheet to each student submission ( open each student submission separate) once that's done I need to grade it and assign a grade. IF IDs match ( student to answer sheet) then it's a point, if they don't it's no point and if the student has a duplicate ID on their submission it's half a point.
When that's done all the duplicates need to get moved to a sheet called Review records sheet and all full point move to the grade sheet. ANy help please as this is what I have and does not run
VBA Code:
Dim i As Integer
Dim Grade As Double
Dim GradePoint As Long
Dim ID As Integer
Dim counter As Integer
Dim FinalGrade As Integer


'Find and Open Reviewed Records File
' user selected a file - do something
userSelectedFile = Application.GetOpenFilename
If userSelectedFile = False Then
MsgBox "No file Selected."
Else
' user selected a file - do something
MsgBox "File selected: " & userSelectedFile
Set wbNew = Workbooks.Open(userSelectedFile)
End If

'Find and Open Reviewed Records File
' user selected a file - do something
userSelectedFile = Application.GetOpenFilename
If userSelectedFile = False Then
MsgBox "No file Selected."
Else
' user selected a file - do something
MsgBox "File selected: " & userSelectedFile
Set wbNew = Workbooks.Open(userSelectedFile)
End If
  
For counter = 1 To 1000
FinalGrade = FinalGrade + 1
   
If counter > 0 Then
FinalGrade = FinalGrade + 0.5
           
Else
           
If counter <> 0 Then
FinalGrade = FinalGrade + 0
           
Else
           
If counter = 0 Then
FinalGrade = FinalGrade + 1
           
Else
           
End If
  
  
   
Do
 
For Each ID In Collection
If counter > 0 Then
FinalGrade = FinalGrade + 0.5
        ID = ReviewedRecordsSheet
Else
   
     
If counter = 0 Then
FinalGrade = FinalGrade + 1
        ID = GradeFileSheet
 
Loop Until ID = GradeFile
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
There's no clue as to what that code belongs to - an event? A stand alone procedure? Is it a sub or a function? Not a great idea to leave off the beginning and ending lines :unsure:. One thing you can do is put a break point at the start of the code and do whatever it is that is supposed to trigger it. If it runs, it will stop at the break poing, then you F8 to step thru line by line and see what's going on. Most of the time code runs but people assume it doesn't because it doesn't seem to do anything. However, you seem to be saying that not even the file dialog opens up, so that would be the first order of business.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top