Greetings all,
I am conducting a financial program in VBA to estimate changes in securities, however overuse of the sentence. "Select" to perform various functions makes my program is slow. An example of this is the routine I use to copy the titles from one sheet to another.
Sub CopiarTitulos()
'Contar columnas en pestanna DVPrecios
ultColumna = Sheets("DVPrecios").Cells(5, Columns.Count).End(xlToLeft).Column
Sheets("DVVariaciones").Cells(1, "C") = ultColumna
Sheets("DVVariaciones").Select
Range("C5").Activate
i = 3
'Fin Contar columnas en pestanna DVPrecios
'Copiar titulos en DVVariaciones
While ultColumna >= i
ActiveCell.FormulaR1C1 = "=IF(DVPrecios!RC<>""VALOR LIBROS"",DVPrecios!RC,"""")"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
If Selection.Value = "" Then Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, 1).Select
i = i + 1
Wend
Range("C5").Select
Cells.EntireColumn.AutoFit
' Fin Copiar titulos en DVVariaciones
End Sub
This code works but if I have to copy the program 5,000 titles takes around 40 minutes to run. Please tell me how else I can write the code for me to select a specific cell and copy and paste the value or perform the various actions that need.
Excuse my translation errors. My English is very bad
Bookmarks