Cho e hỏi là hàm vba này của em, làm sao để trong ô A1 ở sheet3 là công thức thì nó vẫn sRng vẫn hiện giá trị ạ

Liên hệ QC

Busaval

Thành viên mới
Tham gia
6/1/20
Bài viết
2
Được thích
0
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [I4]) Is Nothing Then
Dim Rws As Long, J As Long, Col As Integer, W As Integer
Dim Rng As Range, sRng As Range

Rows("14:16").Hidden = False
With Sheet3
Rws = .[B2].CurrentRegion.Rows.Count
Col = .[B2].CurrentRegion.Columns.Count
ReDim Arr(1 To Col, 1 To 11)
[A14].Resize(Col, 3).Value = Arr()
Set Rng = .[A1].Resize(Rws)
Set sRng = Rng.Find(Target.Value2, , xlFormulas, xlWhole)
If sRng Is Nothing Then
MsgBox "Nothing!", , "GPE.COM Xin Luu Ý!"
Else
Rws = sRng.Row
For J = 1 To Col
If sRng.Offset(, J).Value <> "" Then
W = W + 1: Arr(W, 1) = W
Arr(W, 3) = .Cells(1, J + 1).Value

End If
Next J
End If
End With
If W Then
[A14].Resize(W, 3).Value = Arr()

End If
End If
End Sub
 
thì bạn tìm theo value chứ đừng tìm theo Formulas
 

File đính kèm

  • Phiếu tháng ád.xlsm
    171.2 KB · Đọc: 3
Bạn xem lại find menthol trong diễn đàn đi
 
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [I4]) Is Nothing Then
Dim Rws As Long, J As Long, Col As Integer, W As Integer
Dim Rng As Range, sRng As Range

Rows("14:16").Hidden = False
With Sheet3
Rws = .[B2].CurrentRegion.Rows.Count
Col = .[B2].CurrentRegion.Columns.Count
ReDim Arr(1 To Col, 1 To 11)
[A14].Resize(Col, 3).Value = Arr()
Set Rng = .[A1].Resize(Rws)
Set sRng = Rng.Find(Target.Value2, , xlFormulas, xlWhole)
If sRng Is Nothing Then
MsgBox "Nothing!", , "GPE.COM Xin Luu Ý!"
Else
Rws = sRng.Row
For J = 1 To Col
If sRng.Offset(, J).Value <> "" Then
W = W + 1: Arr(W, 1) = W
Arr(W, 3) = .Cells(1, J + 1).Value

End If
Next J
End If
End With
If W Then
[A14].Resize(W, 3).Value = Arr()

End If
End If
End Sub
Tìm cái sự kiện khác.Cái sự kiện sau khi chạy công thức là được.
 
Web KT
Back
Top Bottom