shuthairah
New Member
hello,
i have some coding that i didn't really know why it can it work
the task is to assign variable to slot with weight
i want to assign the exam with the highest no. of student clashes to the time slot with the highest weight
i get the code but it didn't run well
can anyone help with the coding
the code is
Sub Macro2()
Dim TA, TB As Long
For TB = 1 To Range("Y5").Column - Range("H5").Column + 1
For TA = Range("H5").Column To Range("Y5").Column
If Cells(5, TA) = WorksheetFunction.Large(Range("H5:Y5"), TB) Then
Cells(6, TA) = WorksheetFunction.Large(Range("B2:B25"), TB)
End If
If Cells(7, TA) = WorksheetFunction.Large(Range("H7:Y7"), TB) Then
Cells(8, TA) = WorksheetFunction.Large(Range("B2:B25"), TB)
End If
Next TA
Next TB
End Sub
it do assign to column but have some problem, went i try the code msg box will came out and said
"run-time error 1004: unable to get the Large property of worksheetfunction class"
and when i click debug it highlight
"If Cells(7, TA) = WorksheetFunction.Large(Range("H7:Y7"), TB) Then"
can anyone help with the coding please
i have some coding that i didn't really know why it can it work
the task is to assign variable to slot with weight
i want to assign the exam with the highest no. of student clashes to the time slot with the highest weight
i get the code but it didn't run well
can anyone help with the coding
the code is
Sub Macro2()
Dim TA, TB As Long
For TB = 1 To Range("Y5").Column - Range("H5").Column + 1
For TA = Range("H5").Column To Range("Y5").Column
If Cells(5, TA) = WorksheetFunction.Large(Range("H5:Y5"), TB) Then
Cells(6, TA) = WorksheetFunction.Large(Range("B2:B25"), TB)
End If
If Cells(7, TA) = WorksheetFunction.Large(Range("H7:Y7"), TB) Then
Cells(8, TA) = WorksheetFunction.Large(Range("B2:B25"), TB)
End If
Next TA
Next TB
End Sub
it do assign to column but have some problem, went i try the code msg box will came out and said
"run-time error 1004: unable to get the Large property of worksheetfunction class"
and when i click debug it highlight
"If Cells(7, TA) = WorksheetFunction.Large(Range("H7:Y7"), TB) Then"
can anyone help with the coding please