adua29
Real-life Girls Super Сasual Dating
- Tham gia
- 29/4/08
- Bài viết
- 162
- Được thích
- 113
- Giới tính
- Nam
- Nghề nghiệp
- Health
Nhờ các anh chị tăng tốc 2 hàm sau:
Function dungsai(chuoi As Range, maxa As Byte, maxo As Byte, nx As Boolean)
Dim m, N, i, j As Byte
Dim trung As Boolean
Dim bebe As String
trung = True
bebe = WorksheetFunction.Trim(chuoi.Value)
If nx = False And Len(bebe) > maxo Then
trung = False
End If
If nx = True And Len(bebe) < (maxa - maxo) Then
trung = False
End If
For i = 1 To Len(bebe)
For j = i + 1 To Len(bebe)
If Mid(bebe, i, 1) = Mid(bebe, j, 1) Then
trung = False
End If
Next
If Mid(bebe, i, 1) > maxa Then
trung = False
End If
Next
dungsai = trung
End Function
Function dem(vung As Range, maxd As Long, nxd As Boolean)
Dim cls As Range, Rng As Range
Dim tong As Long
For Each cls In vung
Set Rng = cls.Find("*" & maxd & "*", LookIn:=xlValues, LookAt:=xlWhole)
If nxd = False And Not Rng Is Nothing And cls.Value > 0 Then
tong = tong + 1
Else
If nxd = True And Rng Is Nothing And cls.Value > 0 Then
tong = tong + 1
End If
End If
Next
dem = tong
End Function
Trên máy của em khi sử dụng hàm dungsai, hàm đưa ra kết quả sau 1 - 1,5 giây
Nhờ các anh chị tìm giải pháp tăng tốc độ để hàm xử lý được nhanh hơn
Function dungsai(chuoi As Range, maxa As Byte, maxo As Byte, nx As Boolean)
Dim m, N, i, j As Byte
Dim trung As Boolean
Dim bebe As String
trung = True
bebe = WorksheetFunction.Trim(chuoi.Value)
If nx = False And Len(bebe) > maxo Then
trung = False
End If
If nx = True And Len(bebe) < (maxa - maxo) Then
trung = False
End If
For i = 1 To Len(bebe)
For j = i + 1 To Len(bebe)
If Mid(bebe, i, 1) = Mid(bebe, j, 1) Then
trung = False
End If
Next
If Mid(bebe, i, 1) > maxa Then
trung = False
End If
Next
dungsai = trung
End Function
Function dem(vung As Range, maxd As Long, nxd As Boolean)
Dim cls As Range, Rng As Range
Dim tong As Long
For Each cls In vung
Set Rng = cls.Find("*" & maxd & "*", LookIn:=xlValues, LookAt:=xlWhole)
If nxd = False And Not Rng Is Nothing And cls.Value > 0 Then
tong = tong + 1
Else
If nxd = True And Rng Is Nothing And cls.Value > 0 Then
tong = tong + 1
End If
End If
Next
dem = tong
End Function
Trên máy của em khi sử dụng hàm dungsai, hàm đưa ra kết quả sau 1 - 1,5 giây
Nhờ các anh chị tìm giải pháp tăng tốc độ để hàm xử lý được nhanh hơn

