1
I am new in VB and I am trying to make an operation that copies some information from the spreadsheet "Control Backup Clients" to the spreadsheet "LOG". The process will be as follows: Excel when detecting change in any cell of the column N of the sheet "Control Backup Clients", should copy the respective value of column A (called client code) and paste in the next blank line of the sheet "LOG", where will be recorded all the changes made.
Below follows the code I did, but every time it presents error of "Required Object" and I can not find the problem
Dim celChave As Range
Dim codCliente As Long
Private Sub Worksheet_Change(ByVal Target As Range)
'celChaves onde fica guardado as celulas que serão alteradas
Set celChave = Sheets("Controle Backup Clientes").Range("N2:N1048576")
If Not Application.Intersect(celChave, Range(Target.Address)) _
Is Nothing Then
codCliente = Sheets("Controle Backup Clientes").Select(0, 1)
Sheets("LOG").Select(1048576, 1).End(x1Up).Offset(1, 0).Paste
Application.CutCopyMode = False
Sheets(Sheets("LOG").Select(1048576, 1).End(x1Up).Offset(0, 1)).FormulaR1C1 = "=TODAY()"
Sheets(Sheets("LOG").Select(1048576, 1).End(x1Up).Offset(0, 2)).Paste = codCliente
MsgBox "CORREÇÃO SALVA NO LOG! CELULA (" & Target.Address & ")"
End If
End Sub
Behold this answer, avoid the use of select and on which line the error is presented?
– danieltakeshi
Another detail:
Range(Target.Address)
It seems to me to be a redundancy, becauseTarget
is already aRange
. Moreover, as Daniel has already pointed out, it is essential to say in which line the error happened. I drove here in Excel and only gave error in usSelects
, because of the invalid syntax, but it was not required object (bad method was called).– César Rodriguez
Thanks @danieltakeshi for the tips, helped me a lot!
– Stephen Willians