Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then
Dim Rws As Long
If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then
With Sheet2
Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1
.Cells(Rws, "C").Value = [I1].Value
Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D")
MsgBox "Xong Rôi!", , "GPE.COM Xin Chào!"
End With
End If
End If
End Sub
Em cảm ơn ah, em đã làm được rùi ahBạn xài macro sự kiện này:
PHP:Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then Dim Rws As Long If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then With Sheet2 Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1 .Cells(Rws, "C").Value = [I1].Value Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D") MsgBox "Xong Rôi!", , "GPE.COM Xin Chào!" End With End If End If End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Dg As Long 'X '
If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then
Dim Rws As Long
On Error GoTo GPE
If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then
Dg = Target.Row
With Sheet2
Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1
.Cells(Rws, "C").Value = [I1].Value
Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D")
.Cells(Rws, "A").Value = Cells(Target.Row, "B").Value 'STT '
End With
End If
End If
If Dg Then 'X => '
Rows(Dg & ":" & Dg).Delete
End If '<= X '
Exit Sub
GPE: MsgBox "Xong Rôi!", , "GPE.COM Xin Chào!"
End Sub
PHP:Private Sub Worksheet_Change(ByVal Target As Range) Dim Dg As Long 'X ' If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then Dim Rws As Long On Error GoTo GPE If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then Dg = Target.Row With Sheet2 Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1 .Cells(Rws, "C").Value = [I1].Value Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D") .Cells(Rws, "A").Value = Cells(Target.Row, "B").Value 'STT ' End With End If End If If Dg Then 'X => ' Rows(Dg & ":" & Dg).Delete End If '<= X ' Exit Sub GPE: MsgBox "Xong Rôi!", , "GPE.COM Xin Chào!" End Sub
Bạn bỏ dòng có chữ đó lác xongEm muốn xóa chữ xong rùi ah, mong anh chị giúp
mình bỏ rùi nhưng chạy lại báo lỗi, vì mình chưa hiểu nhiều về macBạn bỏ dòng có chữ đó lác xong
Private Sub Worksheet_Change(ByVal Target As Range)mình bỏ rùi nhưng chạy lại báo lỗi, vì mình chưa hiểu nhiều về mac
Bạn thử lạimình bỏ rùi nhưng chạy lại báo lỗi, vì mình chưa hiểu nhiều về mac
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Dg As Long 'X '
If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then
Dim Rws As Long
On Error GoTo GPE
If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then
Dg = Target.Row
With Sheet2
Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1
.Cells(Rws, "C").Value = [I1].Value
Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D")
.Cells(Rws, "A").Value = Cells(Target.Row, "B").Value 'STT '
End With
End If
End If
If Dg Then 'X => '
Rows(Dg & ":" & Dg).Delete
End If '<= X '
GPE: Exit Sub
End Sub
Bạn thử lại
Mã:Private Sub Worksheet_Change(ByVal Target As Range) Dim Dg As Long 'X ' If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then Dim Rws As Long On Error GoTo GPE If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then Dg = Target.Row With Sheet2 Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1 .Cells(Rws, "C").Value = [I1].Value Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D") .Cells(Rws, "A").Value = Cells(Target.Row, "B").Value 'STT ' End With End If End If If Dg Then 'X => ' Rows(Dg & ":" & Dg).Delete End If '<= X ' GPE: Exit Sub End Sub
Thoa thử lạiBị mất thông báo xong rồi, nhưng lại bị cắt bạn đó từ file data ah
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Dg As Long 'X '
If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then
Dim Rws As Long
On Error GoTo GPE
If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then
Dg = Target.Row
With Sheet2
Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1
.Cells(Rws, "C").Value = [I1].Value
Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D")
.Cells(Rws, "A").Value = Cells(Target.Row, "B").Value 'STT '
End With
End If
End If
GPE: Exit Sub
End Sub
Anh ơi, khi nhập lý do vào thì nó không nhảy ra khoảng trắng ah, mà lý do vẫn xuất hiện ở đó ahThoa thử lại
Mã:Private Sub Worksheet_Change(ByVal Target As Range) Dim Dg As Long 'X ' If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then Dim Rws As Long On Error GoTo GPE If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then Dg = Target.Row With Sheet2 Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1 .Cells(Rws, "C").Value = [I1].Value Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D") .Cells(Rws, "A").Value = Cells(Target.Row, "B").Value 'STT ' End With End If End If GPE: Exit Sub End Sub
Là nhập xong xóa lý do đúng không?Anh ơi, khi nhập lý do vào thì nó không nhảy ra khoảng trắng ah, mà lý do vẫn xuất hiện ở đó ah
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Dg As Long 'X '
If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then
Dim Rws As Long
On Error GoTo GPE
If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then
Dg = Target.Row
With Sheet2
Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1
.Cells(Rws, "C").Value = [I1].Value
Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D")
.Cells(Rws, "A").Value = Cells(Target.Row, "B").Value 'STT '
End With
End If
End If
Range("I4:I1000").ClearContents
GPE: Exit Sub
End Sub
ok đúng rùi ah, em cảm ơn anh nhìu nhéLà nhập xong xóa lý do đúng không?
Mã:Private Sub Worksheet_Change(ByVal Target As Range) Dim Dg As Long 'X ' If Not Intersect(Target, [I4].Resize([B3].CurrentRegion.Rows.Count)) Is Nothing Then Dim Rws As Long On Error GoTo GPE If Cells(Target.Row, "C").Value <> "" And Target.Value <> "" Then Dg = Target.Row With Sheet2 Rws = .Cells(Cells.Rows.Count, "C").End(xlUp).Row + 1 .Cells(Rws, "C").Value = [I1].Value Cells(Target.Row, "C").Resize(, 7).Copy Destination:=.Cells(Rws, "D") .Cells(Rws, "A").Value = Cells(Target.Row, "B").Value 'STT ' End With End If End If Range("I4:I1000").ClearContents GPE: Exit Sub End Sub