Results 1 to 5 of 5

Wait time but without freezing (time to dowload data in cells)

Threaded View

bryan444 Wait time but without... 12-06-2012, 10:20 AM
bryan444 Re: Wait time but without... 12-06-2012, 10:35 AM
Sindhus Re: Wait time but without... 12-06-2012, 10:36 AM
bryan444 Re: Wait time but without... 12-06-2012, 10:38 AM
Sindhus Re: Wait time but without... 12-06-2012, 10:39 AM
  1. #1
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Wait time but without freezing (time to dowload data in cells)

    Hi

    I'd like to know if you guys have a solution to just make a pause without freezing excel
    It is in order to download in cells with the Bloomberg function data before copying them as you can see in this code
    With this code, Excel stops working instead of downloading the data

    Sub getquotes()
    Dim ws As Worksheet
    Dim rngTkr As Range
    Dim strTkr As String
    Dim c As Range
    Set ws = Sheet1
    Dim strFld As String
    
    'Données pour la seconde etape
    Dim rngTkr2 As Range
    Dim d As Range
    
    'transposition des stocks + chopper les données de bloomberg
    Range("heud").ClearContents
    With ws
        Set rngTkr = .Range("A5: A1500").SpecialCells(xlCellTypeConstants) ' ticker range
           i = 1
        For Each c In rngTkr
    
             strTkr = """" & c.Value & " Equity" & """"
             strFld = """" & "PX LAST" & """"
             .Range("A1").Offset(4, i + 1).Value = "=BDH(" & strTkr & "," & strFld & ",B1, B2)"
             .Range("A1").Offset(3, i + 1).Value = c.Value
             i = i + 2
        Next
    End With
    
    Application.Wait (Now + TimeValue("0:00:03"))
    
    '************************** I'D LIKE TO PUT A PAUSE HERE BUT with application.wait it freezes so excel stops working instead of downloading the data
    
     
    Call copydata
    
    End Sub
    
    Sub copydata()
    
        Dim lngCounter As Long
        Dim lngMax As Long
        Dim lngCol As Long
        Dim wksTwo As Worksheet
        Dim rngTkr As Range
        Dim c As Range
            
         'copier de la sheet1 a la sheet2, on copie en valeurs
        Set wksTwo = Worksheets("Sheet2")
         
        wksTwo.Cells.ClearContents
        Worksheets("Sheet3").Cells.ClearContents
        Worksheets("Sheet4").Cells.ClearContents
        
        Worksheets("Sheet1").Range("zoneselect").Copy
        wksTwo.Range("B1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
         
         ' On enleve les blancs entre la sheet 2 à la sheet3
        wksTwo.Range("A1:BB1").Copy Sheets("Sheet3").Range("B1")
        Sheets("Sheet3").Range("B1").CurrentRegion.SpecialCells(xlCellTypeBlanks).Delete shift:=xlToLeft
        Worksheets("Sheet3").Select
        Range("A1:BB1").Select
        Selection.Cut
        Sheets("Sheet3").Select
        Range("B1").Select
        ActiveSheet.Paste
        Selection.SpecialCells(xlCellTypeBlanks).Select
        Application.CutCopyMode = False
        Selection.Delete shift:=xlToLeft
        
        
    '************************ Technique pour prendre la periode personnalisee au début en Workday**************************
    Dim datStart As Long
    Dim datEnd As Long
    Dim lngRow As Long
    datStart = Range("datedebut")
    datEnd = Range("datefin")
    
    lngRow = 2
    
    For lngCounter = datStart To datEnd
      With Worksheets("Sheet3").Cells(lngRow, "A")
      If (WorksheetFunction.Weekday(CDate(lngCounter), 1) < 7) And (WorksheetFunction.Weekday(CDate(lngCounter), 1) > 1) Then
          .Value = CDate(lngCounter)
          lngRow = lngRow + 1
        End If
      End With
    Next lngCounter
    
    
         LgDep = 2   ' Ligne de départ du tableau dans la page Sheet2
      ClDep = 2   ' Colonne de départ du tableau dans la page Sheet2
    
      With Sheets("Sheet2")
        ClFin = .Cells(LgDep, Columns.Count).End(xlToLeft).Column
        LgFin = .Range(.Cells(1, ClDep), .Cells(1, ClFin)).EntireColumn.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
      End With
      Nblg = Range("A" & Rows.Count).End(xlUp).Row
      For i = ClDep To ClFin Step 2
        With Range(Cells(2, 2 + (i - ClDep) / 2), Cells(Nblg, 2 + (i - ClDep) / 2))
          .Formula = "=VLOOKUP(RC1,Sheet2!R" & LgDep & "C" & i & ":R" & Nblg & "C" & i + 1 & ",2,TRUE)"
        End With
      Next i
    
    'FIN TEST VLOOOKUP FORMULE EXCEL
      
          Cells.Select
        Selection.Copy
        Sheets("Sheet4").Select
        Cells.Select
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
            xlNone, SkipBlanks:=False, Transpose:=False
            
     Range("A1").Select
      
    
    
    End Sub
    
    Sub londoncalling()
    Call getquotes
    End Sub

    here is the file (but you wont see the data because you probably won't open the file from a Bloomberg equipied machine ;-)
    https://docs.google.com/open?id=0B1X...nRDOW5HRndCWms

    Best regards



    R
    Last edited by bryan444; 12-06-2012 at 10:22 AM.

Thread Information

Users Browsing this Thread

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

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