Results 1 to 2 of 2

overuse of the sentence ".Select" to perform various functions makes my program is slow

Threaded View

yosma overuse of the sentence... 01-03-2013, 09:47 PM
JBeaucaire Re: overuse of the sentence... 01-05-2013, 03:31 PM
  1. #1
    Registered User
    Join Date
    12-28-2012
    Location
    brazil
    MS-Off Ver
    Excel 2003
    Posts
    4

    overuse of the sentence ".Select" to perform various functions makes my program is slow

    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
    Last edited by yosma; 01-03-2013 at 11:05 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1