Hi all... first post here. I tried looking for this in various Copy/Paste threads but couldn't find exactly what I needed...
The following code works fine except for the fact that it takes a long time (2 to 3 secs in 5 lines) for this for loop to run and I'd like it to do the pasting in the background without changing to the destination (for archiving) sheet at all. In reality, the pasting is just for later use, the end user won't use it.
Thanks in advance...
(as a side note: I'm starting to use VB again and I would appreciate any suggestions to simplify the code...)
The following code works fine except for the fact that it takes a long time (2 to 3 secs in 5 lines) for this for loop to run and I'd like it to do the pasting in the background without changing to the destination (for archiving) sheet at all. In reality, the pasting is just for later use, the end user won't use it.
Code:
numlineas = WorksheetFunction.Sum(Range("a17:a36"))
contador = 0
Set rng = Sheets("Alta Pedido").Range("a17:a36")
Set primlinea = Sheets("Alta Pedido").Range("a16:i16") 'header row in table from where to offset
For Each contador In rng If contador < numlineas Then
Sheets("Alta Pedido").Range("b7").Copy Worksheets("Datos Cotizaciones").Range("A1").End(xlDown).Offset(1, 0)
'Selection.Activate
'MsgBox (contador)
Sheets("Alta Pedido").Range("B8:B14").Copy
Worksheets("Datos Cotizaciones").Range("A1").End(xlDown).Offset(0, 2).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets("Alta Pedido").Range("e8:e10").Copy
Worksheets("Datos Cotizaciones").Range("A1").End(xlDown).Offset(0, 9).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
primlinea.Offset(contador, 0).Copy
Worksheets("Datos Cotizaciones").Range("A1").End(xlDown).Offset(0, 12).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Else
Worksheets("Alta pedido").Activate
Application.CutCopyMode = False
Exit For
End If
Next contador
Thanks in advance...
(as a side note: I'm starting to use VB again and I would appreciate any suggestions to simplify the code...)