caico9x
Thành viên mới

- Tham gia
- 28/7/13
- Bài viết
- 48
- Được thích
- 4
Tôi có 2 đoạn code này dùng để ghép môn, ghép lớp trong Lịch báo giảng, nhưng nó chạy quá chậm, kính mong các bác giúp đỡ
CẢM ƠN CÁC BẠN
Mã:
Mã:
Public Function GetMon(t As Integer, d As Date, n As Integer, tkb As Range) As String
Dim r As Range
Dim nr As Integer
Dim i As Integer
Dim st As Integer
nr = 0
For Each r In tkb.Rows
nr = nr + 1
Next
i = 1
While (tkb.Cells(i + 1, 1).Value <> vbEmpty) And (tkb.Cells(i + 1, 1).Value <= d) And (i < nr)
i = i + 1
Wend
GetMon = tkb.Cells(i, (t - 2) * 10 + n * 2).Value
End Function
---------------------------------
Public Function GetLop(t As Integer, d As Date, n As Integer, tkb As Range) As String
Dim r As Range
Dim nr As Integer
Dim i As Integer
nr = 0
For Each r In tkb.Rows
nr = nr + 1
Next
i = 1
While (tkb.Cells(i + 1, 1).Value <> vbEmpty) And (tkb.Cells(i + 1, 1).Value <= d) And (i < nr)
i = i + 1
Wend
GetLop = tkb.Cells(i, (t - 2) * 10 + n * 2 + 1).Value
End Function
CẢM ƠN CÁC BẠN