Modificacion2 de codigo que traspasa informacion de una hoja a otra
Recientemente me ayudaron con este codigo hecho por el experto DAN
Private Sub Worksheet_Change(ByVal Target As Range)
'Act.Por.Dante Amor
'ActiveWindow.DisplayVerticalScrollBar = False
'ActiveWindow.DisplayHorizontalScrollBar = False
'ExecuteExcel4Macro ("show.toolbar(""ribbon"",1)")
If Intersect(Target, Range("j7:j920,v7:v920,ah7:ah920,at7:at920,bf7:bf920,br7:br920,cd7:cd920,CP7:CP920,DB7:DB920,DN7:DN920,DZ7:DZ920,EL7:EL920,EX7:EX920,FJ7:FJ920")) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub
If Not IsNumeric(Target) Then Exit Sub
'
Target.Select
Set h1 = Sheets("REP X TURNO")
existe = False
For i = 10 To 23
If h1.Cells(i, "I") = "" Then
existe = True
Exit For
End If
Next
If existe = False Then
MsgBox "Limite de Degustaciones Alcanzado", vbCritical, "ERROR"
Exit Sub
End If
cantidad = Application.InputBox("Cantidad a Degustar: ", "Ingresar", Target)
If cantidad = 0 Or cantidad = "" Then
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
Exit Sub
End If
'
fecha = Application.InputBox("fecha de Degustación: ", "INGRESAR", Format(Cells(965, Target.Column), "MM/DD/yyyy"))
If fecha = 0 Or fecha = "" Then
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
Exit Sub
End If
'
h1.Unprotect
h1.Cells(i, "I") = cantidad & " " & Cells(Target.Row, "B") 'Cantidad y producto
h1.Cells(i, "J") = fecha 'Fecha
h1.Cells(i, "K") = Cells(Target.Row, "C") * cantidad 'Cantidad * precio
h1.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
End Sub
Funciona realmente excelente todo lo que necesitaba...
Pero como lo fui usando me salio otro detalle no del codigo si no en la forma de trabajar mia..
el detalle es el sig...
al poner en alguna celda de estos rangos:
If Intersect(Target, Range("j7:j920,v7:v920,ah7:ah920,at7:at920,bf7:bf920,br7:br920,cd7:cd920,CP7:CP920,DB7:DB920,DN7:DN920,DZ7:DZ920,EL7:EL920,EX7:EX920,FJ7:FJ920")) Is Nothing Then Exit Sub
este me pone el numero ingresado en:
cantidad = Application.InputBox("Cantidad a Degustar: ", "Ingresar", Target)
posteriormente la fecha:
fecha = Application.InputBox("fecha de Degustación: ", "INGRESAR",
Si le dan cancelar este no procede y borra la cantidad que yo puse en la celda de mi rango lo cual es genial...
Pero usando el codigo me tope con el problema mio...
Una vez ejecutado el codigo este ya se paso a donde indica y se protege...
Lo que necesito es:
Que si en "BF200" yo puse 5 de cantidad y se ejecuta el codigo bien y todo eso...
Quisiera que si en "BF200" al eliminar la cantidad que puse entonces tambien se elimine los datos que se traspasaron ala hoja destino..
Eso es el detalle la eliminacion de cantidad en la hoja original y que tambien elimine los datos pegados en la hoja destino..


