phuongnaruto
Thành viên mới

- Tham gia
- 20/2/14
- Bài viết
- 1
- Được thích
- 0
Các cao thủ cho em hỏi e sử dụng code sau để tìm kiếm một từ trong chuỗi ký tự dài thì nó đã bôi đỏ đậm cho em từ đó, nhưng sau đó em ctlr+z để từ đó trở về định dạng ban đầu do trong chuỗi text đó có nhiều loại định dạng khác nhau ngầm thể hiện ý nghĩa khác nhau, thì nó không thể trở về định dạng ban đầu được mà cố định bị bôi đỏ đậm luôn, các bác cao thủ giúp em với ạ.sau đây là code em sử dụng. Em xin đa tạ.
Sub GPE()
Application.ScreenUpdating = False
Dim Str As String, FindCll As Range, FindCLlAdd As String, i As Long
Str = InputBox("Nhap chuoi can tim:")
Set FindCll = Cells.Find(What:=Str, After:=[IV65536], LookAt:=xlPart)
If FindCll Is Nothing Then Exit Sub
FindCLlAdd = FindCll.Address
Do
i = 1
Do Until InStr(i, FindCll.Value, Str) = 0
i = InStr(i, FindCll.Value, Str)
With FindCll.Characters(Start:=i, Length:=Len(Str)).Font
.FontStyle = "Bold"
.Color = -16776961
End With
i = i + Len(Str)
Loop
Set FindCll = Cells.FindNext(After:=FindCll)
Loop Until FindCll.Address = FindCLlAdd
Application.ScreenUpdating = True
End Sub
Sub GPE()
Application.ScreenUpdating = False
Dim Str As String, FindCll As Range, FindCLlAdd As String, i As Long
Str = InputBox("Nhap chuoi can tim:")
Set FindCll = Cells.Find(What:=Str, After:=[IV65536], LookAt:=xlPart)
If FindCll Is Nothing Then Exit Sub
FindCLlAdd = FindCll.Address
Do
i = 1
Do Until InStr(i, FindCll.Value, Str) = 0
i = InStr(i, FindCll.Value, Str)
With FindCll.Characters(Start:=i, Length:=Len(Str)).Font
.FontStyle = "Bold"
.Color = -16776961
End With
i = i + Len(Str)
Loop
Set FindCll = Cells.FindNext(After:=FindCll)
Loop Until FindCll.Address = FindCLlAdd
Application.ScreenUpdating = True
End Sub