Chào các bạn!!
Mình mới tập viết code VBA nên nhờ các bạn giúp mình debug code này nhé. Mình viết ra code như dưới nhưng khi chạy thì bị lỗi "Object variable or with block variable not set" nhờ mọi người coi giúp mình chỉnh lại nhé
Sub ccdonepep()
Dim rng As Range
Dim rngdata As Range
Set rngdata = Range("g3:g1000000")
Set rng = rngdata.Find("x", LookIn:=xlValues, lookat:=xlWhole)
If Not rng Is Nothing Then
Do
Sheets("Verifying").Select
Sheets("Verifying").Protect Password:="lamqb1", userinterfaceonly:=True
Application.ScreenUpdating = False
Sheets("PEPs").Select
Rows.Find("x", LookIn:=xlValues, lookat:=xlWhole).Select
ActiveCell = Now
ActiveCell.EntireRow.Select
Selection.Cut
Sheets("Verifying").Select
Rows("4:4").EntireRow.Select
Selection.Insert Shift:=xlDown
Sheets("PEPs").Select
Selection.Delete Shift:=xlUp
Loop
Else
MsgBox ("Not Selected Item!")
End If
End Sub
Mình mới tập viết code VBA nên nhờ các bạn giúp mình debug code này nhé. Mình viết ra code như dưới nhưng khi chạy thì bị lỗi "Object variable or with block variable not set" nhờ mọi người coi giúp mình chỉnh lại nhé
Sub ccdonepep()
Dim rng As Range
Dim rngdata As Range
Set rngdata = Range("g3:g1000000")
Set rng = rngdata.Find("x", LookIn:=xlValues, lookat:=xlWhole)
If Not rng Is Nothing Then
Do
Sheets("Verifying").Select
Sheets("Verifying").Protect Password:="lamqb1", userinterfaceonly:=True
Application.ScreenUpdating = False
Sheets("PEPs").Select
Rows.Find("x", LookIn:=xlValues, lookat:=xlWhole).Select
ActiveCell = Now
ActiveCell.EntireRow.Select
Selection.Cut
Sheets("Verifying").Select
Rows("4:4").EntireRow.Select
Selection.Insert Shift:=xlDown
Sheets("PEPs").Select
Selection.Delete Shift:=xlUp
Loop
Else
MsgBox ("Not Selected Item!")
End If
End Sub