+ Reply to Thread
Results 1 to 2 of 2

do if loop

  1. #1
    bozo the clown
    Guest

    do if loop

    I am trying to write a loop. If a condition is met then run the code and
    return back to the "do if" statement. I have one that works but it maxs out
    the cpu and is slow(see below). Is there anything better?

    Sub Time_set()
    If Range("A65536") < Range("A65536").Offset(0, 2) Then
    Range("A39999:AD39999").Select
    Selection.Delete Shift:=xlUp
    Range("C65536").Select
    ActiveCell.FormulaR1C1 = "=CURRENCIES!R[-65535]C"
    Range("D65536").Select
    ActiveCell.FormulaR1C1 = "=CURRENCIES!R[-65535]C[-2]"
    ActiveCell.Offset(0, -1).Range("A1:B1").Select
    Selection.Copy
    ActiveCell.Offset(0, -2).Range("A1").Select
    ActiveCell.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False

    Range("E65535:AD65535").Select
    Selection.AutoFill Destination:=Range("E65535:AD65536"), Type:= _
    xlFillDefault
    Range("E65535:AD65536").Select
    Else

    End If
    Application.OnTime Now + TimeValue("00:00:01"), "time_set"

    End Sub

  2. #2
    Jim Thomlinson
    Guest

    RE: do if loop

    turn of the automaitic calculations

    application.calclation = xlmanual
    'Your code

    application.calculation = xlAutomatic
    end sub

    --
    HTH...

    Jim Thomlinson


    "bozo the clown" wrote:

    > I am trying to write a loop. If a condition is met then run the code and
    > return back to the "do if" statement. I have one that works but it maxs out
    > the cpu and is slow(see below). Is there anything better?
    >
    > Sub Time_set()
    > If Range("A65536") < Range("A65536").Offset(0, 2) Then
    > Range("A39999:AD39999").Select
    > Selection.Delete Shift:=xlUp
    > Range("C65536").Select
    > ActiveCell.FormulaR1C1 = "=CURRENCIES!R[-65535]C"
    > Range("D65536").Select
    > ActiveCell.FormulaR1C1 = "=CURRENCIES!R[-65535]C[-2]"
    > ActiveCell.Offset(0, -1).Range("A1:B1").Select
    > Selection.Copy
    > ActiveCell.Offset(0, -2).Range("A1").Select
    > ActiveCell.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    > False, Transpose:=False
    >
    > Range("E65535:AD65535").Select
    > Selection.AutoFill Destination:=Range("E65535:AD65536"), Type:= _
    > xlFillDefault
    > Range("E65535:AD65536").Select
    > Else
    >
    > End If
    > Application.OnTime Now + TimeValue("00:00:01"), "time_set"
    >
    > End Sub


+ Reply to Thread

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