các AC cho em hỏi có phải phương thức clearcontens xóa luôn công thức phải không. Ví dụ như trong ô B4:B10 có sử dụng hàm Vlookup thì khi viết .[$B$4:$B$10].clearcontens thì nó xóa luôn công thức .
Thử như sau:thế có cách nào xóa mà không ảnh hưởng tới CT không Anh.Chỉ xóa Value thôi!
Range("B4:B10").SpecialCells(xlCellTypeConstants, 23).ClearContents
Anh chỉnh dùm em đoạn code nàyở dòng chữ đỏ:
Private Sub CommandButton1_Click()
Dim Arr(), Rngs(), i As Long, k As Long
With Sheet1
Rngs = .Range(.[B8], .[B65000].End(xlUp)).Resize(, 5).Value
ReDim Arr(1 To UBound(Rngs, 1), 1 To 6)
For i = 1 To UBound(Rngs, 1)
If Rngs(i, 1) <> "" Then
k = k + 1
Arr(k, 1) = .[C3].Value
Arr(k, 2) = .[C4].Value
Arr(k, 3) = Rngs(i, 1)
Arr(k, 4) = Rngs(i, 2)
Arr(k, 5) = Rngs(i, 3)
Arr(k, 6) = Rngs(i, 5)
End If
Next i
.[C3:C4].ClearContents<= Chỉ xóa Value thôi
.[B8:F100].ClearContents<=Chỉ xóa Value thôi
.[C3].Select
End With
If k Then Sheet4.Range("A65000").End(xlUp).Offset(1).Resize(k, 6).Value = Arr
End Sub
'.........
.Range("C3:C4").SpecialCells(xlCellTypeConstants, 23).ClearContents
.Range("B8:F100").SpecialCells(xlCellTypeConstants, 23).ClearContents
'..............
Sử dụng chức năng Help thì đọc được cái này:Anh cho em hỏi số 23 nghĩa là gí ạ?
.[C3:C4].SpecialCells(2).ClearContents