toandev
Thành viên mới 

			
		- Tham gia
 - 25/9/15
 
- Bài viết
 - 5
 
- Được thích
 - 1
 
- Nghề nghiệp
 - Students
 


Em up thêm file rồi, thầy giúp em nhéThì dùng Find thôi.
Còn nếu muốn người khác cầy hộ, code từ A đến Z thì: đính kèm tập tin -> tốt nhất lấy thêm vd. là với B thì kết quả bằng ngần này ngần này. Không ai viết code trong notepad.
Còn nếu nước bọt suông thì cố gắng đợi thêm.
Function DemDapAn(ByVal sDapAn As String) As Long
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
        .ClearFormatting
        .Font.Underline = wdUnderlineSingle
        .Text = sDapAn
        .Forward = True
        .Format = True
        .Wrap = wdFindStop
        .MatchCase = True
        Application.ScreenUpdating = False
        Do While .Execute
            DemDapAn = DemDapAn + 1
        Loop
        Application.ScreenUpdating = True
    End With
End Function
Sub Test()
Dim sDapAn As String
sDapAn = InputBox("Dem dap an:")
MsgBox DemDapAn(sDapAn)
End Sub
	
Tuyệt quá thầy/cô. Cảm ơn thầyBạn thử code này xem.
Mã:Function DemDapAn(ByVal sDapAn As String) As Long Selection.HomeKey Unit:=wdStory With Selection.Find .ClearFormatting .Font.Underline = wdUnderlineSingle .Text = sDapAn .Forward = True .Format = True .Wrap = wdFindStop .MatchCase = True Application.ScreenUpdating = False Do While .Execute DemDapAn = DemDapAn + 1 Loop Application.ScreenUpdating = True End With End Function Sub Test() Dim sDapAn As String sDapAn = InputBox("Dem dap an:") MsgBox DemDapAn(sDapAn) End Sub