Dynamic VBA matching for 365 days in each column

Dku0903

New Member
Joined
Nov 1, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I am trying to create a weekly attendance calculation for a set of students with roll no in Column A in both sheets as reference. If a student have enrolled in a course it will be a new row entry in sheet 2, therefore for each student based on the number of courses they took they have multiple row entry with a start date and end date for each course.
Sheet 1 has unique roll numbers for each student and a column for each week for the year, I have to run a VBA to match Sheet 2 each roll number to sheet1 and then add +1 for each subject part of that week based on the start date and end date for the course.
Can someone help me make a simple VBA code for this. I tried to make something but it seems to be bugged.

LR1 = Worksheet("Course").Cells(Rows.Count, "A").End(xlUp).Row
CL1 = Worksheet("Attendance").Cells(1, Columns.Count).End(xlToLeft).Column

For i = 2 To ActiveSheet.ListObjects("Attendance").ListRows.Count
For j = 4 To LR1
If Worksheet("Attendance").Cells(i, 1).Value = Worksheet("Course").Cells(j, 1) Then

Dim rng As Range
Set rng = Worksheet("Course").Range(Cell(i, 2), Cell(i, CL1))
rng.Formula = "if(AND(" Worksheet("Course").Cells(j, 8)>Worksheet("Attendance").B$1
Worksheet("Attendance").Cell(i,2).value = Worksheet("Attendance").Cell(i,2).value +1


End If
Next j
Next i
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,215,062
Messages
6,122,925
Members
449,094
Latest member
teemeren

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