If Range("M4:M" & dongcuoi).Value = vbNull Then
Range("M4:M" & dongcuoi).Value = Range("K4:K" & dongcuoi).Value
End If
Mình có dòng code này.
Nếu giả sử value ở cột M là rỗng, thì sẽ nhận giá trị của cột K.
Và nếu giá trị của cột K khác rỗng, thì keep giá chị. Nhưng mình với viết được 1 vế trên thì lỗi báo debug rồi.
chào bạn bạn thêm điều kiện else if nữa nhé.
Chào thầy . Mình đã bổ sung rồi nhưng không ra.
Vẫn báo lỗi mismatch
If Range("M4:M" & dongcuoi).Value = vbNull Then
Range("M4:M" & dongcuoi).Value = Range("K4:K" & dongcuoi).Value
ElseIf Range("M4:M" & dongcuoi).Value <> "" Then
Range("M4:M" & dongcuoi).Value = Range("M4:M" & dongcuoi).Value
End If
Chào bạn bạn thử code sau
Sub TestIsEmpty()
If WorksheetFunction.CountA(Range("m4:m")) = 0 Then
MsgBox "Empty"
Range("M4:M" & dongcuoi).Value = Range("K4:K" & dongcuoi).Value
Else
Range("M4:M" & dongcuoi).Value = Range("M4:M" & dongcuoi).Value
End If
End Sub