Results 1 to 4 of 4

Thread: [RESOLVED] Looking to make this macro Faster

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2020
    Posts
    24

    Resolved [RESOLVED] Looking to make this macro Faster

    Code:
    Sub STEP16()
    Dim wb1 As Workbook
    Dim ws1 As Worksheet
    Set wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\HotStocks\1.xls")
    Set ws1 = wb1.Worksheets.Item(1)
    With ws1
    
        Range("O2").Select
        ActiveCell.FormulaR1C1 = "100"
        Range("O2").Select
        Selection.Copy
        Range("K2").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
            SkipBlanks:=False, Transpose:=False
            
    End With
            
    wb1.Save
    wb1.Close
    
    End Sub

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: Looking to make this macro Faster

    Not sure i understood what you're trying to do
    Aircode:
    Code:
    ......
    Dim i As Long
    With WS1
      Range("O2")=100
      For i=2 To UsedRange.Rows.Count
         Range("K" & i)=Range("K" & i)*Range("O2")
      Next
    End With
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Looking to make this macro Faster

    depending how many rows are involved, i am sure it would be faster to to read the values into an array, do the calculation, then write the array back to the range

    or probably even faster, use an array formula
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2020
    Posts
    24

    Re: Looking to make this macro Faster

    Thnx Alot Both of u For ur Great Tips

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width