Sé que sé. Hay un montón de sugerencias sobre cómo resolver ese problema en particular, pero de alguna manera todas tienden a fallar conmigo.
Lo que tengo (simplificado): A (Mac) Excel-Sheet "Output" con:
Name Time Date
Mike 08:00 01.01.2016
La segunda fila está produciendo los datos basados en alguna entrada en otra hoja.
Lo que necesito: Siempre que cambie la segunda fila de "Salida" (es decir, cambie la entrada), puedo hacer clic en un botón para agregar la segunda fila completa a una nueva hoja de trabajo "Registro" (que también incluirá un encabezado). Básicamente, registrar los datos al hacer clic en el botón. Los datos solo se pueden agregar una vez, se eliminan varias entradas de los mismos datos. Después de registrar los datos en "Registro", no es necesario borrar la segunda fila de "Salida", sin embargo, no debería poder agregar los mismos datos nuevamente.
¿Alguna idea?
*EDITAR
Modifiqué el código desde aquí: http://goo.gl/48jjDo.
Sub Submit()
Application.ScreenUpdating = False
Dim refTable As Variant, trans As Variant
refTable = Array("A = A2", "B = B2", "C=C2")
Dim Row As Long
Row = Worksheets("Log").UsedRange.Rows.Count + 1
For Each trans In refTable
Dim Dest As String, Field As String
Dest = Trim(Left(trans, InStr(1, trans, "=") - 1)) & Row
Field = Trim(Right(trans, Len(trans) - InStr(1, trans, "=")))
Worksheets("Log").Range(Dest).value = Worksheets("Output").Range(Field).value
Next
Application.ScreenUpdating = True
End Sub
* Editar2
Ok, esto me llevó más lejos:
Sub CopyRangeFromSheet1toSheet2()
Dim lastRow As Long
lastRow = Sheets("Sheet2").Range("A100000").End(xlUp).Row + 1 " then next free row in sheet2
Sheets("Sheet1").Range("A2:C2").Copy Destination:=Sheets("Sheet2").Range("A" & lastRow)
End Sub
Sin embargo, ¿cómo verifico ahora si hay varios datos? Y tendré que pegar solo los valores.
Respuestas
0 para la respuesta № 1Hasta ahora esto funciona:
Sub CopyFormulas()
Dim sht1 As Worksheet, sht2 As Worksheet
Set sht1 = Sheets("Output")
Set sht2 = Sheets("Log")
sht1.Range("A2:C2").Copy
sht2.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
response = MsgBox("data was added")
End Sub
No, solo falta la comprobación de varias entradas