Viết code tìm kiếm trong excel (1 người xem)

  • Thread starter Thread starter Scor.
  • Ngày gửi Ngày gửi
Liên hệ QC

Người dùng đang xem chủ đề này

Scor.

Thành viên mới
Tham gia
25/3/13
Bài viết
1
Được thích
0
Chào các cao thủ, nhờ các cao thủ sửa hộ em đoạn code như file đính kèm. em mới học VB nên không rành lắm.

em cảm ơn các cao thủ.
 

File đính kèm

Bạn thử với con này xem sao

PHP:
Option Explicit
Private Sub Cmdsearch_Click()
Dim Search As String, sRng As Range

Search = TextBox1.Text

If Search = "" Then
    MsgBox "XIN VUI LONG NHAP TEN CAN TIM", , " MESSAGE"
    Exit Sub
Else
    Set sRng = Cells.Find(What:=Search, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
    If sRng Is Nothing Then
        MsgBox " XIN LOI VI KHONG TIM THAY, CAM ON BAN", , "MESSAGE"
    Else
        MsgBox sRng.Address
    End If
End If
End Sub
 
Upvote 0
PHP:
Option Explicit
Private Sub Cmdsearch_Click()
Dim Search As String, sRng As Range

Search = TextBox1.Text

If Search = "" Then
    MsgBox "XIN VUI LONG NHAP TEN CAN TIM", , " MESSAGE"
    Exit Sub
Else
    Set sRng = Cells.Find(What:=Search, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
    If sRng Is Nothing Then
        MsgBox " XIN LOI VI KHONG TIM THAY, CAM ON BAN", , "MESSAGE"
    Else
        MsgBox sRng.Address
    End If
End If
End Sub


Voi doan code nay, minh muon nhay xuong toi dong minh vua tim co duoc ko
 
Upvote 0
Voi doan code nay, minh muon nhay xuong toi dong minh vua tim co duoc ko
Sửa lại như sau
Mã:
Private Sub Cmdsearch_Click()
Dim Search As String, sRng As Range


Search = TextBox1.Text


If Search = "" Then
    MsgBox "XIN VUI LONG NHAP TEN CAN TIM", , " MESSAGE"
    Exit Sub
Else
    Set sRng = Cells.Find(What:=Search, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
    If sRng Is Nothing Then
        MsgBox " XIN LOI VI KHONG TIM THAY, CAM ON BAN", , "MESSAGE"
    Else
             Cells.Find(What:=Search, After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate


    End If
End If
End Sub
 
Upvote 0
Private Sub Cmdsearch_Click()
Dim Search As String, sRng As Range

Search = TextBox1.Text

If Search = "" Then
MsgBox "XIN VUI LONG NHAP TEN CAN TIM", , " MESSAGE"
Exit Sub
Else
Set sRng = Cells.Find(What:=Search, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If sRng Is Nothing Then
MsgBox " XIN LOI VI KHONG TIM THAY, CAM ON BAN", , "MESSAGE"
Else
sRng.Activate ' them cho nay
MsgBox sRng.Address
End If
End If
End Sub
 
Upvote 0
Web KT

Bài viết mới nhất

Back
Top Bottom