Consulting

Results 1 to 3 of 3

Thread: VBA rnus slow in Office 2007

  1. #1

    VBA rnus slow in Office 2007

    Hi,

    I have this following code, which meant to import data from one file to another file. It runs pretty quick in Office 2003, but terribly slow in office 2007. Why?

     
    Sub ShlifaData(s As String)
    Application.DisplayAlerts = False
    Application.ScreenUpdating = False
    Fname = ActiveWindow.Caption
    ph = Range("Path" & s)
    fl = Range("File" & s)
    sh = Range("Sheet" & s)
    shc = ActiveSheet.Name
    Sheets("Data" & s).Select
     
    If Cells(Range("output" & s).Row + 1, Range("formula" & s).Column) <> "" Then _
    Range(Cells(Range("output" & s).Row + 1, Range("formula" & s).Column), _
    Cells(Range("output" & s).End(xlDown).Row, Range("formula" & s).Column + Range("formula" & s).Columns.Count - 1)).Clear
    Application.StatusBar = "Open " & ph & "\" & fl
    Workbooks.Open Filename:=ph & "\" & fl
    'ActiveSheet.Name = sh
    Sheets(sh).Activate
    inp = Range(Range("output" & s), Range("output" & s).End(xlToRight).End(xlDown)).Address
    Windows(Fname).Activate
     
    Workbooks(fl).Sheets(sh).Range(inp).AdvancedFilter _
    Action:=xlFilterCopy, CopyToRange:=Range("output" & s), Unique:=False
    inp = Range(Cells(Range("output" & s).Row, Range("output" & s).Column), _
    Cells(Range("output" & s).End(xlDown).Row, Range("output" & s).Column + Range("output" & s).Columns.Count - 1)).Address
    If Cells(Range("output" & s).Row + 1, Range("output" & s).Column) <> "" Then Call CopyFormula(s)
    Application.CutCopyMode = False
    Windows(fl).Close savechanges:=False
    Sheets(shc).Select
    Application.StatusBar = False
    End Sub
    Thanks,
    Udi

  2. #2
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    1. But what is in procedure CopyFormula?
    2. For what it wanted?:[vba]inp = Range(Cells(Range("output" & s).Row, Range("output" & s).Column), _
    Cells(Range("output" & s).End(xlDown).Row, Range("output" & s).Column + Range("output" & s).Columns.Count - 1)).Address[/vba]You do not use with it further.


    I apologize for my english language.

    Artik

  3. #3
    CopyFormula is :
    Sub CopyFormula(s As String)
      Application.StatusBar = "formula" & s
        Range("formula" & s).Copy
        Range(Cells(Range("output" & s).Row + 1, Range("formula" & s).Column), _
              Cells(Range("output" & s).End(xlDown).Row, Range("formula" & s).Column + Range("formula" & s).Columns.Count - 1)).Select
        Selection.PasteSpecial xlAll
        Selection.Copy
        Selection.PasteSpecial xlValues
        Application.CutCopyMode = False
        Application.StatusBar = False
    End Sub
    The inp = ... is redundant so I have just removed it from the code, but it didn't shorten the time it takes.

Posting Permissions

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